1 // Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
2 // Use of this source code is governed by a apache 2.0 license that can be
3 // found in the LICENSE file.
5 #include "common/step/filesystem/step_remove_per_user_storage_directories.h"
11 #include "common/step/step.h"
12 #include "common/step/filesystem/step_create_storage_directories.h"
13 #include "common/step/filesystem/step_create_globalapp_symlinks.h"
14 #include "common/installer_context.h"
15 #include "common/shared_dirs.h"
16 #include "common/utils/pkgmgr_query.h"
18 namespace common_installer {
19 namespace filesystem {
21 Step::Status StepRemovePerUserStorageDirectories::process() {
22 if (context_->request_mode.get() != RequestMode::GLOBAL)
23 return Step::Status::OK;
25 if (!common_installer::DeletePerUserStorageDirectories(context_->pkgid.get(),
26 context_->keep_rwdata.get()))
27 return Status::APP_DIR_ERROR;
29 return Step::Status::OK;
32 Step::Status StepRemovePerUserStorageDirectories::undo() {
33 std::string author_id =
34 QueryCertificateAuthorCertificate(
35 context_->pkgid.get(), context_->uid.get());
36 context_->certificate_info.get().author_id.set(author_id);
37 std::vector<std::unique_ptr<Step>> steps;
38 steps.emplace_back(new StepCreateStorageDirectories(
39 context_, additional_shared_dirs_));
40 steps.emplace_back(new StepCreateGlobalAppSymlinks(context_));
42 for (auto& it : steps) {
44 result = it->precheck();
45 if (result != Step::Status::OK) {
46 LOG(ERROR) << "Fail to execute precheck of " << it->name();
50 result = it->process();
51 if (result != Step::Status::OK) {
52 LOG(ERROR) << "Fail to execute process of " << it->name();
56 return Step::Status::OK;
59 } // namespace filesystem
60 } // namespace common_installer