Remove manifest backup when update recover with cleanup 58/234858/1
authorIlho Kim <ilho159.kim@samsung.com>
Fri, 29 May 2020 08:10:08 +0000 (17:10 +0900)
committerIlho Kim <ilho159.kim@samsung.com>
Fri, 29 May 2020 08:17:06 +0000 (17:17 +0900)
In case update, installer create backup xml file
This backup file should be removed when run recovery with cleanup flag

Change-Id: If517d33729d83c2a7625621c0db17ec52a8fbebb
Signed-off-by: Ilho Kim <ilho159.kim@samsung.com>
src/common/step/filesystem/step_recover_manifest.cc
src/common/step/filesystem/step_recover_manifest.h

index 27244d9..e2cb064 100644 (file)
@@ -44,6 +44,21 @@ Step::Status StepRecoverManifest::RecoveryUpdate() {
   return Status::OK;
 }
 
+Step::Status StepRecoverManifest::Cleanup() {
+  if (!SetXmlPaths()) {
+    LOG(DEBUG) << "Manifest recovery not needed";
+    return Status::OK;
+  }
+  if (bf::exists(context_->backup_xml_path.get())) {
+    if (!Remove(context_->backup_xml_path.get())) {
+      LOG(ERROR) << "Cannot remove backup manifest file";
+      return Status::RECOVERY_ERROR;
+    }
+  }
+  LOG(INFO) << "Manifest recovery done";
+  return Status::OK;
+}
+
 bool StepRecoverManifest::SetXmlPaths() {
   if (context_->pkgid.get().empty())
     return false;
index d53eda4..9fab414 100644 (file)
@@ -27,6 +27,7 @@ class StepRecoverManifest : public recovery::StepRecovery {
 
   Status RecoveryNew() override;
   Status RecoveryUpdate() override;
+  Status Cleanup() override;
 
  private:
   bool SetXmlPaths();