Enable recovery for delta request 19/86119/3
authorTomasz Iwanek <t.iwanek@samsung.com>
Tue, 30 Aug 2016 13:52:38 +0000 (15:52 +0200)
committerTomasz Iwanek <t.iwanek@samsung.com>
Wed, 31 Aug 2016 08:13:20 +0000 (01:13 -0700)
To verify, crash delta update request (killing backend) and run
recovery for package:
 $ backend -b $path_to_created_recovery_file

Package state should be restore to the state before delta update.

Change-Id: I0f6481a81af870cfa5ab9637a46106471b8596a5

src/common/step/configuration/step_configure.cc
src/common/step/filesystem/step_remove_temporary_directory.cc
src/common/step/recovery/step_open_recovery_file.cc
src/common/step/recovery/step_recovery.cc
src/common/step/recovery/step_recovery.h

index 2679eb4..2e5a437 100644 (file)
@@ -115,9 +115,10 @@ Step::Status StepConfigure::process() {
       break;
   }
 
-  // Record recovery file for update and request modes
+  // Record recovery file
   if (pkgmgr_->GetRequestType() == RequestType::Install ||
-      pkgmgr_->GetRequestType() == RequestType::Update) {
+      pkgmgr_->GetRequestType() == RequestType::Update ||
+      pkgmgr_->GetRequestType() == RequestType::Delta) {
     std::unique_ptr<recovery::RecoveryFile> recovery_file =
         recovery::RecoveryFile::CreateRecoveryFileForPath(
             GenerateTemporaryPath(
index 23a2dc8..817c781 100644 (file)
@@ -25,10 +25,13 @@ Step::Status StepRemoveTemporaryDirectory::RecoveryNew() {
 
 void StepRemoveTemporaryDirectory::RemoveFiles() {
   bf::path unpack_dir_path = context_->unpacked_dir_path.get();
+  bf::path patch_dir_path = unpack_dir_path;
+  patch_dir_path += ".patch";
   if (unpack_dir_path.empty())
     return;
   boost::system::error_code error_code;
   bf::remove_all(unpack_dir_path, error_code);
+  bf::remove_all(patch_dir_path, error_code);
   return;
 }
 }  // namespace filesystem
index 848ec0c..38574fb 100644 (file)
@@ -27,6 +27,9 @@ Step::Status StepOpenRecoveryFile::process() {
   case RequestType::Update:
     LOG(INFO) << "Running recovery for update installation";
     break;
+  case RequestType::Delta:
+    LOG(INFO) << "Running recovery for delta installation";
+    break;
   default:
     assert(false && "Not reached");
   }
index 153042b..43f0cf5 100644 (file)
@@ -17,11 +17,17 @@ Step::Status StepRecovery::process() {
     return RecoveryNew();
   case RequestType::Update:
     return RecoveryUpdate();
+  case RequestType::Delta:
+    return RecoveryDelta();
   default:
     LOG(ERROR) << "Recovery is not supported for given type of installation";
     return Status::RECOVERY_ERROR;
   }
 }
 
+Step::Status StepRecovery::RecoveryDelta() {
+  return RecoveryUpdate();
+}
+
 }  // namespace recovery
 }  // namespace common_installer
index eea22bc..e72f53e 100644 (file)
@@ -34,6 +34,7 @@ class StepRecovery : public Step {
 
   virtual Status RecoveryNew() = 0;
   virtual Status RecoveryUpdate() = 0;
+  virtual Status RecoveryDelta();
 };
 
 }  // namespace recovery