Refactoring/removing unnecessary branches 64/177264/2
authorTomasz Swierczek <t.swierczek@samsung.com>
Thu, 26 Apr 2018 12:29:40 +0000 (14:29 +0200)
committerTomasz Swierczek <t.swierczek@samsung.com>
Thu, 26 Apr 2018 12:53:28 +0000 (14:53 +0200)
Removal of unnecessary checking of old package hybrid status
& removal of not needed conditional branch in cynara.cpp

Change-Id: Ibceca51adcb94279ab9c3fce3a6521879cfeacd4

src/common/cynara.cpp
src/common/service_impl.cpp

index d094093..d5f2a90 100644 (file)
@@ -367,22 +367,15 @@ void CynaraAdmin::updateAppPolicy(
         bucket = Buckets.at(Bucket::MANIFESTS_LOCAL);
 
         // when app is installed locally add/remove redirection from MANIFESTS_GLOBAL to MANIFESTS_LOCAL
-        if (policyRemove) {
+        if (policyRemove || oldLabel != newLabel) {
             newPolicies.push_back(CynaraAdminPolicy(
                 oldLabel,
                 cynaraUser,
                 "*",
                 static_cast<int>(CynaraAdminPolicy::Operation::Delete),
                 Buckets.at(Bucket::MANIFESTS_GLOBAL)));
-        } else {
-            if (oldLabel != newLabel) {
-                newPolicies.push_back(CynaraAdminPolicy(
-                    oldLabel,
-                    cynaraUser,
-                    "*",
-                    static_cast<int>(CynaraAdminPolicy::Operation::Delete),
-                    Buckets.at(Bucket::MANIFESTS_GLOBAL)));
-            }
+        }
+        if (!policyRemove) {
             newPolicies.push_back(CynaraAdminPolicy(
                 newLabel,
                 cynaraUser,
index f67713f..7628aa5 100644 (file)
@@ -737,7 +737,7 @@ int ServiceImpl::appInstall(const Credentials &creds, app_inst_req &req)
 
         InstallHelper ih;
         ih.isUserPkgInstalled = m_privilegeDb.IsUserPkgInstalled(req.pkgName, req.uid);
-        ih.isOldPkgHybrid = m_privilegeDb.IsPackageHybrid(req.pkgName);
+        ih.isOldPkgHybrid = ih.isUserPkgInstalled ? m_privilegeDb.IsPackageHybrid(req.pkgName) : req.isHybrid;
 
         if (ih.isUserPkgInstalled && ih.isOldPkgHybrid != req.isHybrid) {
             LogError("Application conflicts with existing one. " <<
@@ -819,7 +819,7 @@ int ServiceImpl::appUpdate(const Credentials &creds, app_inst_req &req)
 
         InstallHelper ih;
         ih.isUserPkgInstalled = m_privilegeDb.IsUserPkgInstalled(req.pkgName, req.uid);
-        ih.isOldPkgHybrid = m_privilegeDb.IsPackageHybrid(req.pkgName);
+        ih.isOldPkgHybrid = ih.isUserPkgInstalled ? m_privilegeDb.IsPackageHybrid(req.pkgName) : req.isHybrid;
 
         if (ih.isUserPkgInstalled and ih.isOldPkgHybrid != req.isHybrid) {
             // search for installed apps in the request