Skip to content

Commit 5cc5919

Browse files
authored
Merge pull request #22270 from brave/remove-old-adblock-components
Remove old adblock components after installing new ones
2 parents e6a27e8 + 97d33dc commit 5cc5919

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

components/brave_shields/core/browser/ad_block_component_filters_provider.cc

+8
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <utility>
1111

1212
#include "base/files/file_path.h"
13+
#include "base/files/file_util.h"
1314
#include "base/task/thread_pool.h"
1415
#include "brave/components/brave_shields/core/browser/ad_block_component_installer.h"
1516
#include "brave/components/brave_shields/core/browser/ad_block_filters_provider.h"
@@ -90,9 +91,16 @@ void AdBlockComponentFiltersProvider::UnregisterComponent() {
9091

9192
void AdBlockComponentFiltersProvider::OnComponentReady(
9293
const base::FilePath& path) {
94+
base::FilePath old_path = component_path_;
9395
component_path_ = path;
9496

9597
NotifyObservers(engine_is_default_);
98+
99+
if (!old_path.empty()) {
100+
base::ThreadPool::PostTask(
101+
FROM_HERE, {base::TaskPriority::BEST_EFFORT},
102+
base::BindOnce(IgnoreResult(&base::DeletePathRecursively), old_path));
103+
}
96104
}
97105

98106
void AdBlockComponentFiltersProvider::LoadFilterSet(

0 commit comments

Comments
 (0)