Skip recover change owner
[platform/core/appfw/app-installers.git] / src / common / step / mount / step_mount_update.cc
index b21d4dd..fcba92d 100644 (file)
@@ -24,6 +24,16 @@ namespace common_installer {
 namespace mount {
 
 Step::Status StepMountUpdate::process() {
+  bs::error_code error;
+
+  if (!bf::exists(backup_path_)) {
+    bf::create_directories(backup_path_, error);
+    if (error) {
+      LOG(ERROR) << "Failed to create backup directory: " << backup_path_;
+      return Status::APP_DIR_ERROR;
+    }
+  }
+
   auto zip_unpack = CreateZipInterface(context_->unpacked_dir_path.get());
   if (!zip_unpack->UnmountZip()) {
     LOG(ERROR) << "Failed to unmount zip package from temporary path";
@@ -74,6 +84,9 @@ Step::Status StepMountUpdate::clean() {
           context_->GetPkgPath(), context_->pkgid.get()));
   Remove(backup_zip_location);
 
+  if (bf::exists(backup_path_))
+    RemoveAll(backup_path_);
+
   return Status::OK;
 }
 
@@ -103,6 +116,10 @@ Step::Status StepMountUpdate::undo() {
       return Status::APP_DIR_ERROR;
     }
   }
+
+  if (bf::exists(backup_path_))
+    RemoveAll(backup_path_);
+
   return Status::OK;
 }
 
@@ -134,6 +151,8 @@ Step::Status StepMountUpdate::precheck() {
     return Step::Status::PACKAGE_NOT_FOUND;
   }
 
+  backup_path_ = GetBackupPathForPackagePath(context_->GetPkgPath());
+
   return Step::Status::OK;
 }