std::cerr << "Failed to get db path, cannot remove old databases";
return;
}
- std::string journal = "-journal";
- std::string parser_db_journal = parser_db + journal;
bs::error_code error;
- bf::path info_db_path(parser_db);
- bf::path info_db_journal_path(parser_db_journal.c_str());
+ std::vector<bf::path> file_list;
+ file_list.emplace_back(bf::path(parser_db));
+ file_list.emplace_back(bf::path(std::string(parser_db) + "-shm"));
+ file_list.emplace_back(bf::path(std::string(parser_db) + "-wal"));
+ free(parser_db);
+ for (auto& path : file_list) {
+ bf::remove(path, error);
+ if (error)
+ std::cerr << path << " is not removed" << std::endl;
+ }
+ file_list.clear();
- bf::remove(info_db_path, error);
- if (error)
- std::cerr << info_db_path << " is not removed" << std::endl;
- bf::remove(info_db_journal_path, error);
- if (error)
- std::cerr << info_db_journal_path << " is not removed" << std::endl;
if (IsGlobal(uid)) {
char *cert_db = getUserPkgCertDBPath();
if (!cert_db) {
std::cerr << "Failed to get cert db path" << std::endl;
- free(parser_db);
return;
}
- std::string cert_db_journal = cert_db + journal;
- bf::path cert_db_path(cert_db);
- bf::path cert_db_journal_path(cert_db_journal.c_str());
- bf::remove(cert_db_path, error);
- if (error)
- std::cerr << cert_db_path << " is not removed" << std::endl;
- bf::remove(cert_db_journal_path, error);
- if (error)
- std::cerr << cert_db_journal_path << " is not removed" << std::endl;
+ file_list.emplace_back(bf::path(cert_db));
+ file_list.emplace_back(bf::path(std::string(cert_db) + "-shm"));
+ file_list.emplace_back(bf::path(std::string(cert_db) + "-wal"));
free(cert_db);
+ for (auto& path : file_list) {
+ bf::remove(path, error);
+ if (error)
+ std::cerr << path << " is not removed" << std::endl;
+ }
}
-
- free(parser_db);
}
} // namespace