Use pkgmgr API to get the parser db path
[platform/core/appfw/app-installers.git] / src / pkg_initdb / pkg_initdb.cc
index fc9cf21..0df326b 100644 (file)
@@ -81,18 +81,17 @@ void InitdbLoadDirectory(uid_t uid, const bf::path& directory, bool preload) {
 }
 
 void RemoveOldDatabases(uid_t uid) {
-  if (!IsGlobal(uid))
-    tzplatform_set_user(uid);
+  char *parser_db = getUserPkgParserDBPathUID(uid);
+  char *cert_db = getUserPkgCertDBPathUID(uid);
+  std::string journal = "-journal";
+  std::string parser_db_journal = parser_db + journal;
+  std::string cert_db_journal = cert_db + journal;
 
   bs::error_code error;
-  bf::path info_db_path(tzplatform_mkpath(
-      IsGlobal(uid) ? TZ_SYS_DB : TZ_USER_DB, ".pkgmgr_parser.db"));
-  bf::path info_db_journal_path(tzplatform_mkpath(
-      IsGlobal(uid) ? TZ_SYS_DB : TZ_USER_DB, ".pkgmgr_parser.db-journal"));
-  bf::path cert_db_path(tzplatform_mkpath(
-      IsGlobal(uid) ? TZ_SYS_DB : TZ_USER_DB, ".pkgmgr_cert.db"));
-  bf::path  cert_db_journal_path(tzplatform_mkpath(
-      IsGlobal(uid) ? TZ_SYS_DB : TZ_USER_DB, ".pkgmgr_cert.db-journal"));
+  bf::path info_db_path(parser_db);
+  bf::path info_db_journal_path(parser_db_journal.c_str());
+  bf::path cert_db_path(cert_db);
+  bf::path cert_db_journal_path(cert_db_journal.c_str());
 
   bf::remove(info_db_path, error);
   if (error)
@@ -107,7 +106,8 @@ void RemoveOldDatabases(uid_t uid) {
   if (error)
     std::cerr << cert_db_journal_path << " is not removed" << std::endl;
 
-  tzplatform_reset_user();
+  free(cert_db);
+  free(parser_db);
 }
 
 }  // namespace