Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes https everywhere not working with existing database. #13143

Merged
merged 1 commit into from
Apr 25, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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