summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorilho kim <ilho159.kim@samsung.com>2023-01-12 14:24:27 +0900
committerilho kim <ilho159.kim@samsung.com>2023-01-13 07:30:20 +0000
commit8107d7c771baf5bbb9f61d1b2d7acdbd3c2572f4 (patch)
treeef57b4ec0d3b56ab0e47325b9e9610f4c25b813f
parenta8c90f5debe53f069cbdea65994cc61bf718bad5 (diff)
downloadapp-installers-8107d7c771baf5bbb9f61d1b2d7acdbd3c2572f4.tar.gz
app-installers-8107d7c771baf5bbb9f61d1b2d7acdbd3c2572f4.tar.bz2
app-installers-8107d7c771baf5bbb9f61d1b2d7acdbd3c2572f4.zip
Implement Cleanup in StepMountRecover
Implement Cleanup in StepMountRecover to remove the zip path backed up Change-Id: Ia9e2d760dfb04598a2780f9410f41ff80c885618 Signed-off-by: ilho kim <ilho159.kim@samsung.com>
-rw-r--r--src/common/step/mount/step_mount_recover.cc27
-rw-r--r--src/common/step/mount/step_mount_recover.h1
2 files changed, 28 insertions, 0 deletions
diff --git a/src/common/step/mount/step_mount_recover.cc b/src/common/step/mount/step_mount_recover.cc
index e922b0cb..65e1c3b4 100644
--- a/src/common/step/mount/step_mount_recover.cc
+++ b/src/common/step/mount/step_mount_recover.cc
@@ -9,6 +9,7 @@
#include <pkgmgrinfo_basic.h>
+#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 d74f0436..9236b76f 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;