From: ilho kim Date: Thu, 12 Jan 2023 05:24:27 +0000 (+0900) Subject: Implement Cleanup in StepMountRecover X-Git-Tag: accepted/tizen/7.0/unified/20230117.141737~3 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fappfw%2Fapp-installers.git;a=commitdiff_plain;h=8107d7c771baf5bbb9f61d1b2d7acdbd3c2572f4 Implement Cleanup in StepMountRecover Implement Cleanup in StepMountRecover to remove the zip path backed up Change-Id: Ia9e2d760dfb04598a2780f9410f41ff80c885618 Signed-off-by: ilho kim --- diff --git a/src/common/step/mount/step_mount_recover.cc b/src/common/step/mount/step_mount_recover.cc index e922b0c..65e1c3b 100644 --- a/src/common/step/mount/step_mount_recover.cc +++ b/src/common/step/mount/step_mount_recover.cc @@ -9,6 +9,7 @@ #include +#include "common/utils/file_util.h" #include "common/utils/paths.h" #include "common/tzip_interface.h" #include "common/zip_interface.h" @@ -35,6 +36,32 @@ Step::Status StepMountRecover::RecoveryMountUpdate() { return Status::OK; } +Step::Status StepMountRecover::Cleanup() { + recovery::RecoveryFile* recovery_file = + context_->recovery_info.get().recovery_file.get(); + if (!recovery_file) { + LOG(ERROR) << "Failed to get recovery info"; + return Status::RECOVERY_ERROR; + } + + if (recovery_file->type() != RequestType::MountUpdate) + return Status::OK; + + bf::path zip_destination_path = + GetZipPackageLocation(context_->GetPkgPath(), context_->pkgid.get()); + bf::path backup_zip_location = GetBackupPathForZipFile(zip_destination_path); + + if (bf::exists(backup_zip_location)) { + if (!Remove(backup_zip_location)) { + LOG(ERROR) << "Fail to remove backup zip location : " + << backup_zip_location; + return Status::RECOVERY_ERROR; + } + } + + return Status::OK; +} + Step::Status StepMountRecover::clean() { recovery::RecoveryFile* recovery_file = context_->recovery_info.get().recovery_file.get(); diff --git a/src/common/step/mount/step_mount_recover.h b/src/common/step/mount/step_mount_recover.h index d74f043..9236b76 100644 --- a/src/common/step/mount/step_mount_recover.h +++ b/src/common/step/mount/step_mount_recover.h @@ -27,6 +27,7 @@ class StepMountRecover : public MountBase, public recovery::StepRecovery { Status RecoveryDelta() override { return Status::OK; } Status RecoveryMountNew() override { return Status::OK; } Status RecoveryMountUpdate() override; + Status Cleanup() override; Status clean() override; Status undo() override;