Call CLEANUP type plugin when cleanup recovery case 48/319948/5
authorIlho Kim <ilho159.kim@samsung.com>
Thu, 20 Feb 2025 06:36:09 +0000 (15:36 +0900)
committerIlho Kim <ilho159.kim@samsung.com>
Wed, 5 Mar 2025 07:57:19 +0000 (16:57 +0900)
Change-Id: I24e1bf4d6a7cd8318ee69cbf2831b656d00d4297
Signed-off-by: Ilho Kim <ilho159.kim@samsung.com>
src/common/plugins/category_plugin.cc
src/common/plugins/metadata_plugin.cc
src/common/plugins/plugin.h
src/common/plugins/tag_plugin.cc
src/common/step/pkgmgr/step_recover_parser_plugins.cc
src/common/step/pkgmgr/step_recover_parser_plugins.h

index f0596878f2dac79f434b5091e2b47d222fbbff7e..3fab73868f8898606c33d3ccbdcf2a0ce20461f9 100644 (file)
@@ -93,6 +93,7 @@ std::string CategoryPlugin::GetFunctionName(ActionType action) const {
     {ActionType::Clean, "PKGMGR_CATEGORY_PARSER_PLUGIN_CLEAN"},
     {ActionType::Undo, "PKGMGR_CATEGORY_PARSER_PLUGIN_UNDO"},
     {ActionType::Removed, "PKGMGR_CATEGORY_PARSER_PLUGIN_REMOVED"},
+    {ActionType::CleanUp, "PKGMGR_CATEGORY_PARSER_PLUGIN_CLEANUP"},
   };
 
   auto pos = names.find(action);
index c92b187ed0bb89cfe0b4f48dc34e3db5a35e8833..4e40c86fa9c0dd5d34b191810c52792812568c3d 100644 (file)
@@ -116,6 +116,7 @@ std::string MetadataPlugin::GetFunctionName(ActionType action) const {
     {ActionType::Clean, "PKGMGR_MDPARSER_PLUGIN_CLEAN"},
     {ActionType::Undo, "PKGMGR_MDPARSER_PLUGIN_UNDO"},
     {ActionType::Removed, "PKGMGR_MDPARSER_PLUGIN_REMOVED"},
+    {ActionType::CleanUp, "PKGMGR_MDPARSER_PLUGIN_CLEANUP"},
   };
 
   auto pos = names.find(action);
index bee8ec369d3534d71dc09639c8146df20068b597..a699974ce38a00c96769a26ba37bc2f574a8413f 100644 (file)
@@ -35,7 +35,8 @@ class Plugin {
       RecoverInstall,
       RecoverUpgrade,
       RecoverUninstall,
-      Removed
+      Removed,
+      CleanUp
   };
   enum class ProcessType { Pre, Main, Post };
 
index 3fca08f529c916b17e67058b5224a685cd705d40..27c2b4df3ab1ca87720034067a1b06722b97d349 100644 (file)
@@ -37,6 +37,7 @@ std::string TagPlugin::GetFunctionName(ProcessType process,
     {{ActionType::RecoverUninstall, ProcessType::Main},  "PKGMGR_PARSER_PLUGIN_RECOVERUNINSTALL"}, // NOLINT
     {{ActionType::Clean, ProcessType::Main},  "PKGMGR_PARSER_PLUGIN_CLEAN"}, // NOLINT
     {{ActionType::Undo, ProcessType::Main},  "PKGMGR_PARSER_PLUGIN_UNDO"}, // NOLINT
+    {{ActionType::CleanUp, ProcessType::Main},  "PKGMGR_PARSER_PLUGIN_CLEANUP"}, // NOLINT
     {{ActionType::Install,   ProcessType::Post}, "PKGMGR_PARSER_PLUGIN_POST_INSTALL"},  // NOLINT
     {{ActionType::Upgrade,   ProcessType::Post}, "PKGMGR_PARSER_PLUGIN_POST_UPGRADE"},  // NOLINT
     {{ActionType::Uninstall, ProcessType::Post}, "PKGMGR_PARSER_PLUGIN_POST_UNINSTALL"}, // NOLINT
index d1b917e59cf4bb16c5a4fbb6717fbb4e8bd9c937..006330b6a1123403c92420ec8d64b58a53f6ae6f 100644 (file)
@@ -38,7 +38,11 @@ ci::Plugin::ActionType GetActionType(ci::InstallerContext* context) {
 }
 
 bool IsNeedToUseBackupManifest(ci::InstallerContext* context) {
-  ci::RequestType type = context->recovery_info.get().recovery_file->type();
+  auto& recovery_file = context->recovery_info.get().recovery_file;
+  if (recovery_file->cleanup())
+    return false;
+
+  ci::RequestType type = recovery_file->type();
   if (type == ci::RequestType::Update || type == ci::RequestType::Delta ||
       type == ci::RequestType::MountUpdate)
     return true;
@@ -52,20 +56,26 @@ namespace common_installer {
 namespace pkgmgr {
 
 Step::Status StepRecoverParserPlugin::RecoveryNew() {
-  return RecoverPlugin();
+  return RecoverPlugin(GetActionType(context_));
 }
 
 Step::Status StepRecoverParserPlugin::RecoveryUpdate() {
-  return RecoverPlugin();
+  return RecoverPlugin(GetActionType(context_));
+}
+
+
+Step::Status StepRecoverParserPlugin::Cleanup() {
+  return RecoverPlugin(Plugin::ActionType::CleanUp);
 }
 
-Step::Status StepRecoverParserPlugin::RecoverPlugin() {
+Step::Status StepRecoverParserPlugin::RecoverPlugin(
+    Plugin::ActionType action_type) {
   if (!SetXmlPath()) {
     LOG(ERROR) << "Failed to set xml path for plugin, but continue";
     return Status::OK;
   }
   plugin_ =
-      std::make_unique<StepRunParserPlugin>(context_, GetActionType(context_));
+      std::make_unique<StepRunParserPlugin>(context_, action_type);
   if (plugin_->process() != Step::Status::OK) {
     LOG(ERROR) << "Failed to execute plugin properly, but continue";
     return Status::OK;
index 60d49dd6206f5935fb2e0866afa0630ac05f42da..7403c6d560e180cfa8f9fb9f5b09ccd25b223349 100644 (file)
@@ -10,6 +10,7 @@
 #include <memory>
 
 #include "common/installer_context.h"
+#include "common/plugins/plugin.h"
 #include "common/step/pkgmgr/step_run_parser_plugins.h"
 #include "common/step/recovery/step_recovery.h"
 
@@ -22,9 +23,10 @@ class StepRecoverParserPlugin : public recovery::StepRecovery {
 
   Status RecoveryNew() override;
   Status RecoveryUpdate() override;
+  Status Cleanup() override;
 
  private:
-  Status RecoverPlugin();
+  Status RecoverPlugin(Plugin::ActionType action_type);
   bool SetXmlPath();
 
   std::unique_ptr<StepRunParserPlugin> plugin_;