Skip to content

Commit

Permalink
Merge pull request #13157 from brave/pr13143_maxk-fix-https-everywher…
Browse files Browse the repository at this point in the history
…e_1.38.x

Fixes https everywhere not working with existing database. (uplift to 1.38.x)
  • Loading branch information
kjozwiak authored Apr 25, 2022
2 parents a47b792 + 1417aa3 commit dccc467
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions components/brave_shields/browser/https_everywhere_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include "base/base_paths.h"
#include "base/bind.h"
#include "base/files/file_util.h"
#include "base/json/json_reader.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
Expand Down Expand Up @@ -90,6 +91,15 @@ void HTTPSEverywhereService::Engine::Init(const base::FilePath& base_dir) {
base_dir.AppendASCII(DAT_FILE_VERSION).AppendASCII(DAT_FILE);
base::FilePath unzipped_level_db_path = zip_db_file_path.RemoveExtension();
base::FilePath destination = zip_db_file_path.DirName();
// Unzip doesn't allow overwriting existing files, so delete previously
// unzipped db. Attempting to delete a non-existent path returns success.
bool deleted = base::DeletePathRecursively(unzipped_level_db_path);
if (!deleted) {
LOG(ERROR) << "Failed to delete unzipped database directory "
<< unzipped_level_db_path.value().c_str();
return;
}

if (!zip::Unzip(zip_db_file_path, destination)) {
LOG(ERROR) << "Failed to unzip database file "
<< zip_db_file_path.value().c_str();
Expand Down

0 comments on commit dccc467

Please sign in to comment.