From: Ilho Kim Date: Thu, 30 Jun 2022 06:16:28 +0000 (+0900) Subject: Implement undo of RemovePerUserStorageDirectories X-Git-Tag: accepted/tizen/unified/20220825.135043~2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fappfw%2Fapp-installers.git;a=commitdiff_plain;h=47a1eb6a0495bae396cffadf3029d0e0f411e2c1 Implement undo of RemovePerUserStorageDirectories If the uninstallation is failed after this step, there is a problem that the user directory remains erased so recreate the user directories removed by this step Change-Id: Ic346217ab1cb971645bff44653027e545a430923 Signed-off-by: Ilho Kim --- diff --git a/src/common/step/filesystem/step_remove_per_user_storage_directories.cc b/src/common/step/filesystem/step_remove_per_user_storage_directories.cc index 9eba913..1a220a1 100644 --- a/src/common/step/filesystem/step_remove_per_user_storage_directories.cc +++ b/src/common/step/filesystem/step_remove_per_user_storage_directories.cc @@ -4,11 +4,16 @@ #include "common/step/filesystem/step_remove_per_user_storage_directories.h" +#include #include #include +#include "common/step/step.h" +#include "common/step/filesystem/step_create_storage_directories.h" +#include "common/step/filesystem/step_create_globalapp_symlinks.h" #include "common/installer_context.h" #include "common/shared_dirs.h" +#include "common/utils/pkgmgr_query.h" namespace common_installer { namespace filesystem { @@ -24,6 +29,32 @@ Step::Status StepRemovePerUserStorageDirectories::process() { return Step::Status::OK; } +Step::Status StepRemovePerUserStorageDirectories::undo() { + std::string author_id = + QueryCertificateAuthorCertificate( + context_->pkgid.get(), context_->uid.get()); + context_->certificate_info.get().author_id.set(author_id); + std::vector> steps; + steps.emplace_back(new StepCreateStorageDirectories(context_)); + steps.emplace_back(new StepCreateGlobalAppSymlinks(context_)); + + for (auto& it : steps) { + Step::Status result; + result = it->precheck(); + if (result != Step::Status::OK) { + LOG(ERROR) << "Fail to execute precheck of " << it->name(); + return result; + } + + result = it->process(); + if (result != Step::Status::OK) { + LOG(ERROR) << "Fail to execute process of " << it->name(); + return result; + } + } + return Step::Status::OK; +} + } // namespace filesystem } // namespace common_installer diff --git a/src/common/step/filesystem/step_remove_per_user_storage_directories.h b/src/common/step/filesystem/step_remove_per_user_storage_directories.h index 5dcae94..2669d4a 100644 --- a/src/common/step/filesystem/step_remove_per_user_storage_directories.h +++ b/src/common/step/filesystem/step_remove_per_user_storage_directories.h @@ -30,7 +30,7 @@ class StepRemovePerUserStorageDirectories : public common_installer::Step { Status process() override; Status clean() override { return Status::OK; } - Status undo() override { return Status::OK; } + Status undo() override; Status precheck() override { return Status::OK; } STEP_NAME(RemovePerUserStorageDirectories)