From: ilho kim Date: Mon, 22 Jul 2019 05:33:25 +0000 (+0000) Subject: Revert "Change database removal logic" X-Git-Tag: accepted/tizen/unified/20190723.053623~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F19%2F210519%2F3;p=platform%2Fcore%2Fappfw%2Fapp-installers.git Revert "Change database removal logic" This reverts commit 66f0018a9d36e6f6638f7272d80245c9b5cb5858. Change-Id: Ifa278212372491fa9f9f565cbf87b3ea2ff9258e --- diff --git a/src/pkg_initdb/pkg_initdb.cc b/src/pkg_initdb/pkg_initdb.cc index 69b1b15..5d54558 100644 --- a/src/pkg_initdb/pkg_initdb.cc +++ b/src/pkg_initdb/pkg_initdb.cc @@ -120,38 +120,41 @@ void RemoveOldDatabases(uid_t uid) { 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; - std::vector 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); + bf::path info_db_path(parser_db); + bf::path info_db_journal_path(parser_db_journal.c_str()); - 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()); - 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")); + 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; 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