Implement unified recovery feature 02/234402/3
authorJunghyun Yeon <jungh.yeon@samsung.com>
Tue, 26 May 2020 06:18:10 +0000 (15:18 +0900)
committerJunghyun Yeon <jungh.yeon@samsung.com>
Fri, 29 May 2020 06:47:22 +0000 (15:47 +0900)
Recovery will be performed for package to be installed together.
Even if certain package's operation has finished, It will be revoked
if other package operation has failed which are requested at once.
In addition, Unified backend will handle recovery for single package.

Change-Id: Ia540a4a92eb53d5b3a97e497165058ab129ee0e5
Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
src/unified/unified_installer_factory.cc

index f29aca78d1b1872cad1e0c6628e1ac2b7dc006e8..fed7accc8c4268007cc841710f97d4f33fc0da4e 100644 (file)
@@ -6,6 +6,8 @@
 
 #include <unzip.h>
 
+#include <boost/filesystem/path.hpp>
+
 #include <manifest_parser/utils/logging.h>
 #include <hybrid/hybrid_installer.h>
 #include <tpk/tpk_app_query_interface.h>
@@ -53,6 +55,15 @@ std::string GetPkgTypeFromPath(const std::string& path) {
   return type;
 }
 
+std::string GetPkgTypeFromFilename(const boost::filesystem::path& name) {
+  std::string filename = name.string();
+  std::string token;
+  std::stringstream ss(filename);
+
+  std::getline(ss, token, '-');
+  return token;
+}
+
 }  // namespace
 
 namespace common_installer {
@@ -61,9 +72,14 @@ std::unique_ptr<AppInstaller> UnifiedInstallerFactory::CreateInstaller(
     PkgMgrPtr pkgmgr, int idx) {
   std::string type = GetPkgTypeFromPkgid(pkgmgr->GetRequestInfo(idx),
       pkgmgr->GetUid());
+
   if (type.empty())
     type = GetPkgTypeFromPath(pkgmgr->GetRequestInfo(idx));
 
+  if (type.empty())
+    type = GetPkgTypeFromFilename(
+        boost::filesystem::path(pkgmgr->GetRequestInfo(idx)).filename());
+
   if (type.empty())
     return {};