Fix StepRecoverStorageDirectories 64/59764/3
authorTomasz Iwanek <t.iwanek@samsung.com>
Thu, 18 Feb 2016 08:38:58 +0000 (09:38 +0100)
committerTomasz Iwanek <t.iwanek@samsung.com>
Tue, 23 Feb 2016 09:58:19 +0000 (01:58 -0800)
Recovery will be broken if update installation breaks before
coping files. This step was breaking directory structure in
this case because of wrong check.

Change-Id: Ica3875f52b045163e8e169fd7ea296636c4aa89c

src/common/step/step_recover_storage_directories.cc

index a9600d9..95fb033 100644 (file)
@@ -25,6 +25,8 @@ bool StepRecoverStorageDirectories::MoveAppStorage(
     const bf::path& in_dst,
     const char *key) {
   bf::path src = in_src / key;
+  if (!bf::exists(src))
+    return false;
   bf::path dst = in_dst / key;
   return common_installer::MoveDir(src, dst);
 }
@@ -33,7 +35,7 @@ Step::Status StepRecoverStorageDirectories::RecoveryUpdate() {
   if (!context_->pkg_path.get().empty()) {
     bf::path backup_path = common_installer::GetBackupPathForPackagePath(
         context_->pkg_path.get());
-    if (!backup_path.empty()) {
+    if (bf::exists(backup_path)) {
       MoveAppStorage(context_->pkg_path.get(), backup_path, kDataLocation);
       MoveAppStorage(context_->pkg_path.get(), backup_path, kSharedLocation);
     }