Keep system and update value for undo operation 02/271902/1
authorSangyoon Jang <jeremy.jang@samsung.com>
Thu, 3 Mar 2022 05:05:46 +0000 (14:05 +0900)
committerSangyoon Jang <jeremy.jang@samsung.com>
Thu, 3 Mar 2022 05:05:46 +0000 (14:05 +0900)
These value must be set for undo operation.

Change-Id: I5d2896b82c535489bd8795b2357bf6a4cfa3153f
Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>
src/common/step/configuration/step_parse_preload.cc
src/common/step/configuration/step_parse_preload.h

index a09e008..d926bdc 100644 (file)
@@ -213,6 +213,36 @@ ci::Step::Status StepParsePreload::AdjustSystem() {
   return Status::OK;
 }
 
+ci::Step::Status StepParsePreload::AdjustOldManifest() {
+  manifest_x* old_manifest = context_->old_manifest_data.get();
+  if (!old_manifest)
+    return Status::OK;
+
+  free(old_manifest->system);
+  // keep system value for undo operation
+  if (pkg_query_->IsSystemPackage())
+    old_manifest->system = strdup("true");
+  else
+    old_manifest->system = strdup("false");
+  if (!old_manifest->system) {
+    LOG(ERROR) << "Out of memory";
+    return Status::ERROR;
+  }
+
+  free(old_manifest->update);
+  // keep update value for undo operation
+  if (pkg_query_->IsUpdatedPackage())
+    old_manifest->update = strdup("true");
+  else
+    old_manifest->update = strdup("false");
+  if (!old_manifest->update) {
+    LOG(ERROR) << "Out of memory";
+    return Status::ERROR;
+  }
+
+  return Status::OK;
+}
+
 ci::Step::Status StepParsePreload::process() {
   req_type_ = context_->request_type.get();
   pkg_query_.reset(
@@ -241,6 +271,10 @@ ci::Step::Status StepParsePreload::process() {
   if (ret != Status::OK)
     return ret;
 
+  ret = AdjustOldManifest();
+  if (ret != Status::OK)
+    return ret;
+
   return Status::OK;
 }
 
index 01d1541..21cae22 100644 (file)
@@ -33,6 +33,7 @@ class StepParsePreload : public common_installer::Step {
   bool ValidateAttrs();
   Status AdjustUpdate();
   Status AdjustSystem();
+  Status AdjustOldManifest();
 
   common_installer::RequestType req_type_;
   std::unique_ptr<PkgQueryInterface> pkg_query_;