bug-fix : fix TAC malfunction for multi pkg scenario accepted/tizen/unified/20240326.104912 accepted/tizen/unified/x/20240327.045059
authorWoongsuk Cho <ws77.cho@samsung.com>
Fri, 22 Mar 2024 08:21:48 +0000 (17:21 +0900)
committer조웅석/MDE Lab(SR)/삼성전자 <ws77.cho@samsung.com>
Mon, 25 Mar 2024 02:10:39 +0000 (11:10 +0900)
clear vector before restart tac plugin
close tac_db and tlc_db for next package

NativeLauncher/tool/tac_installer.cc

index 88d7953..b8b7b66 100644 (file)
@@ -51,6 +51,17 @@ static tac_state tacState = TAC_STATE_NONE;
 static std::string prevInstallPkgId = std::string("");
 static std::string prevFinishPkgId = std::string("");
 
+// initialize static vector to support multi-package install scenario
+static void tacInitialize()
+{
+       nugetPackagesAssembliesSha.clear();
+       tacDB.clear();
+       createDirectories.clear();
+       createLibraries.clear();
+       updateTac.clear();
+       updateTlc.clear();
+}
+
 static void createSHA256Info(std::string sha256Info, std::string nugetPackage)
 {
        std::ofstream ofs(sha256Info, std::ios::app);
@@ -378,6 +389,8 @@ int tacInstall(const std::string& pkgId, tac_state state, bool tacForce)
        _DBG("[===== PKGMGR_MDPARSER_PLUGIN_INSTALL =====]");
        _INFO("PackageID : %s", pkgId.c_str());
 
+       tacInitialize();
+
        // Can be multiple apps in one package
        if (strcmp(pkgId.c_str(), prevInstallPkgId.c_str()) == 0) {
                _INFO("TAC Plugin(INSTALL) already run for same pkgId (%s)", pkgId.c_str());
@@ -422,16 +435,20 @@ int tacInstall(const std::string& pkgId, tac_state state, bool tacForce)
        }
 
        if (generateTAC(pkgId, binPath) != 0) {
+               tac_closeDB();
                return -1;
        }
 
        ///// TLC /////
        if (tlc_createDB() != 0) {
+               tac_closeDB();
                return -1;
        }
 
        copyLibraryCreateSymlink(pkgId, getLibrariesInfo(rootPath));
 
+       tac_closeDB();
+       tlc_closeDB();
        return 0;
 }
 
@@ -440,6 +457,8 @@ int tacUpgrade(const std::string& pkgId, tac_state state, bool tacForce)
        _DBG("[===== PKGMGR_MDPARSER_PLUGIN_UPGRADE =====]");
        _INFO("PackageID : %s", pkgId.c_str());
 
+       tacInitialize();
+
        // Can be multiple apps in one package
        if (strcmp(pkgId.c_str(), prevInstallPkgId.c_str()) == 0) {
                _INFO("TAC Plugin(UPGRADE) already run for same pkgId (%s)", pkgId.c_str());
@@ -488,6 +507,7 @@ int tacUpgrade(const std::string& pkgId, tac_state state, bool tacForce)
        bool skipTLC = false;
        if (tacDB.empty()) {
                if (tac_deleteDB(pkgId, "") != 0) {
+                       tac_closeDB();
                        return -1;
                }
                tacUpdateDB(pkgId);
@@ -495,6 +515,7 @@ int tacUpgrade(const std::string& pkgId, tac_state state, bool tacForce)
                skipTLC = true;
        } else {
                if (generateTAC(pkgId, binPath) != 0) {
+                       tac_closeDB();
                        return -1;
                }
 
@@ -509,6 +530,7 @@ int tacUpgrade(const std::string& pkgId, tac_state state, bool tacForce)
                        if (!isExits) {
                                if (tac_deleteDB(pkgId, unp) != 0) {
                                        tacState = TAC_STATE_RESTORE;
+                                       tac_closeDB();
                                        return -1;
                                }
                        }
@@ -518,12 +540,15 @@ int tacUpgrade(const std::string& pkgId, tac_state state, bool tacForce)
 
        ///// TLC /////
        if (tlc_createDB() != 0) {
+               tac_closeDB();
                return -1;
        }
 
        updateTlc = tlc_selectDB(pkgId);
 
        if (tlc_deleteDB(pkgId) != 0) {
+               tac_closeDB();
+               tlc_closeDB();
                return -1;
        }
 
@@ -531,6 +556,9 @@ int tacUpgrade(const std::string& pkgId, tac_state state, bool tacForce)
 
        copyLibraryCreateSymlink(pkgId, skipTLC ? std::vector<std::string>() : getLibrariesInfo(rootPath));
 
+       tac_closeDB();
+       tlc_closeDB();
+
        return 0;
 }
 
@@ -539,6 +567,8 @@ int tacUninstall(const std::string& pkgId, tac_state state)
        _DBG("[===== PKGMGR_MDPARSER_PLUGIN_UNINSTALL =====]");
        _INFO("PackageID : %s", pkgId.c_str());
 
+       tacInitialize();
+
        // Can be multiple apps in one package
        if (strcmp(pkgId.c_str(), prevInstallPkgId.c_str()) == 0) {
                _INFO("TAC Plugin(UNINSTALL) already run for same pkgId (%s)", pkgId.c_str());
@@ -555,23 +585,30 @@ int tacUninstall(const std::string& pkgId, tac_state state)
 
        if (tac_deleteDB(pkgId, "") != 0) {
                tacState = TAC_STATE_RESTORE;
+               tac_closeDB();
                return -1;
        }
        tacUpdateDB(pkgId);
 
        ///// TLC /////
        if (tlc_openDB() != 0) {
+               tac_closeDB();
                return -1;
        }
 
        updateTlc = tlc_selectDB(pkgId);
 
        if (tlc_deleteDB(pkgId) != 0) {
+               tac_closeDB();
+               tlc_closeDB();
                return -1;
        }
 
        tlcUpdateDB(pkgId);
 
+       tac_closeDB();
+       tlc_closeDB();
+
        return 0;
 }