Fix StepRecoverParserPlugin 13/317213/3
authorIlho Kim <ilho159.kim@samsung.com>
Fri, 27 Dec 2024 04:19:17 +0000 (13:19 +0900)
committerilho kim <ilho159.kim@samsung.com>
Tue, 31 Dec 2024 00:27:04 +0000 (00:27 +0000)
Some plugins can execute some operations using the destructor of
the object used in the plugin after the installation is completed
so keep the StepRunParserPlugin object as a member variable in
StepRecoverParserPlugin

Change-Id: Iec91be1cea07e1ddada4a99a9791051a6ddbb073
Signed-off-by: Ilho Kim <ilho159.kim@samsung.com>
src/common/step/pkgmgr/step_recover_parser_plugins.cc
src/common/step/pkgmgr/step_recover_parser_plugins.h

index 4513ae99aafdcee91c59c1fe0f76080eb8d56fe4..4c2b93024b1fad70809007c4ee2eac097efd19ee 100644 (file)
@@ -62,8 +62,9 @@ Step::Status StepRecoverParserPlugin::RecoverPlugin() {
     LOG(ERROR) << "Failed to set xml path for plugin, but continue";
     return Status::OK;
   }
-  StepRunParserPlugin plugin(context_, GetActionType(context_));
-  if (plugin.process() != Step::Status::OK) {
+  plugin_ =
+      std::make_unique<StepRunParserPlugin>(context_, GetActionType(context_));
+  if (plugin_->process() != Step::Status::OK) {
     LOG(ERROR) << "Failed to execute plugin properly, but continue";
     return Status::OK;
   }
index 140d08250c223412462de066910c9c5912192be0..60d49dd6206f5935fb2e0866afa0630ac05f42da 100644 (file)
@@ -7,7 +7,10 @@
 
 #include <manifest_parser/utils/logging.h>
 
+#include <memory>
+
 #include "common/installer_context.h"
+#include "common/step/pkgmgr/step_run_parser_plugins.h"
 #include "common/step/recovery/step_recovery.h"
 
 namespace common_installer {
@@ -24,6 +27,8 @@ class StepRecoverParserPlugin : public recovery::StepRecovery {
   Status RecoverPlugin();
   bool SetXmlPath();
 
+  std::unique_ptr<StepRunParserPlugin> plugin_;
+
   STEP_NAME(RecoverParserPlugin)
 };