From: Ilho Kim Date: Fri, 24 Nov 2023 03:50:14 +0000 (+0900) Subject: Implement StepRemoveGlobalAppSymlinks undo X-Git-Tag: accepted/tizen/unified/20241203.164212~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fe8e12b97a589e10c73196ec7b59e9bf43b867b9;p=platform%2Fcore%2Fappfw%2Fapp-installers.git Implement StepRemoveGlobalAppSymlinks undo Change-Id: If4554ca988078802974998eee773b448cee266d2 Signed-off-by: Ilho Kim --- diff --git a/src/common/step/filesystem/step_remove_globalapp_symlinks.cc b/src/common/step/filesystem/step_remove_globalapp_symlinks.cc index 644f20c7..8baf7d94 100644 --- a/src/common/step/filesystem/step_remove_globalapp_symlinks.cc +++ b/src/common/step/filesystem/step_remove_globalapp_symlinks.cc @@ -54,6 +54,30 @@ Step::Status StepRemoveGlobalAppSymlinks::process() { return Step::Status::OK; } +Step::Status StepRemoveGlobalAppSymlinks::undo() { + if (context_->is_readonly_package.get() || + context_->request_mode.get() == RequestMode::USER) + return Step::Status::OK; + + PkgQueryInterface pkg_query(context_->pkgid.get(), kGlobalUserUid); + if (!pkg_query.IsPackageInstalled()) + return Step::Status::OK; + + RequestType req_type = context_->request_type.get(); + if (req_type == RequestType::Uninstall || + req_type == RequestType::ReadonlyUpdateUninstall) { + std::string package_id = context_->pkgid.get(); + LOG(INFO) << "Creating globalapp symlinks for all user, package: " + << package_id; + if (!CreateGlobalAppSymlinksForAllUsers(package_id)) { + LOG(ERROR) << "Failed to create globalapp symlinks"; + return Status::GLOBALSYMLINK_ERROR; + } + } + + return Status::OK; +} + } // namespace filesystem } // namespace common_installer diff --git a/src/common/step/filesystem/step_remove_globalapp_symlinks.h b/src/common/step/filesystem/step_remove_globalapp_symlinks.h index d870382c..61e807bf 100644 --- a/src/common/step/filesystem/step_remove_globalapp_symlinks.h +++ b/src/common/step/filesystem/step_remove_globalapp_symlinks.h @@ -29,7 +29,7 @@ class StepRemoveGlobalAppSymlinks : 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(RemoveGlobalAppSymlinks) 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 2c60121a..409a833b 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 @@ -34,26 +34,10 @@ Step::Status StepRemovePerUserStorageDirectories::undo() { 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_, additional_shared_dirs_)); - 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; + + StepCreateStorageDirectories step(context_, additional_shared_dirs_); + + return step.process(); } } // namespace filesystem