Fix rollback of mount update request 93/87493/4
authorTomasz Iwanek <t.iwanek@samsung.com>
Thu, 8 Sep 2016 08:10:48 +0000 (10:10 +0200)
committerTomasz Iwanek <t.iwanek@samsung.com>
Fri, 9 Sep 2016 13:02:21 +0000 (06:02 -0700)
Rollback operation for mount update should just unmount new content
and restore old zip file to right location.

Check with smoke tests from: https://review.tizen.org/gerrit/#/c/87494/

Change-Id: I6c6d664d3a015919b9d5e67356ee4685b53f65e0

src/common/step/mount/step_mount_update.cc

index ac5a2e8..a2c3e09 100644 (file)
@@ -73,6 +73,13 @@ Step::Status StepMountUpdate::clean() {
 }
 
 Step::Status StepMountUpdate::undo() {
+  bf::path mount_point = GetMountLocation(context_->pkg_path.get());
+  TzipInterface tzip_final(mount_point);
+  if (!tzip_final.UnmountZip()) {
+    LOG(ERROR) << "Failed to unmount zip package after installation";
+    return Status::APP_DIR_ERROR;
+  }
+
   bf::path zip_location = GetZipPackageLocation(
         context_->pkg_path.get(), context_->pkgid.get());
   bf::path backup_zip_location = GetBackupPathForZipFile(zip_location);
@@ -90,12 +97,6 @@ Step::Status StepMountUpdate::undo() {
       return Status::APP_DIR_ERROR;
     }
   }
-  bs::error_code error;
-  bf::remove(context_->pkg_path.get(), error);
-  if (error) {
-    LOG(ERROR) << "Failed to remove package content";
-    return Status::APP_DIR_ERROR;
-  }
   return Status::OK;
 }