From: ilho kim Date: Thu, 12 Jan 2023 00:52:13 +0000 (+0900) Subject: Fix StepCopyBackup's undo operation X-Git-Tag: accepted/tizen/7.0/unified/20230117.141737~2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fappfw%2Fapp-installers.git;a=commitdiff_plain;h=7dc3ecb0ac8498551c6668ffa154155751bcdb59 Fix StepCopyBackup's undo operation Fix the operation of restoring the backup directory which created in the step, the backup directory's ownership and smack label are not set Change-Id: I6d5613461ba4c773c3450a1d61b67d4ed9f13d6b Signed-off-by: ilho kim --- diff --git a/src/common/step/backup/step_copy_backup.cc b/src/common/step/backup/step_copy_backup.cc index 2c5f8ba..82d98e4 100644 --- a/src/common/step/backup/step_copy_backup.cc +++ b/src/common/step/backup/step_copy_backup.cc @@ -276,16 +276,24 @@ bool StepCopyBackup::CleanBackupDirectory() { bool StepCopyBackup::RollbackApplicationDirectory() { bs::error_code error; - if (bf::exists(context_->GetPkgPath())) { - bf::remove_all(context_->GetPkgPath(), error); - if (error) { - return false; + bf::path root_path = context_->GetPkgPath(); + if (bf::exists(root_path)) { + for (bf::directory_iterator iter(root_path); + iter != bf::directory_iterator(); ++iter) { + bf::remove_all(iter->path(), error); + if (error) + return false; } } - if (!MoveDir(backup_path_, context_->GetPkgPath())) { - return false; + for (bf::directory_iterator iter(backup_path_); + iter != bf::directory_iterator(); ++iter) { + if (!Move(iter->path(), root_path)) { + LOG(ERROR) << "Failed to recovery backup file(" << iter->path() << ")"; + return false; + } } + RemoveAll(backup_path_); uid_t uid = context_->uid.get(); // restore ownership changed during installation