Remove boost dependency
[platform/core/appfw/app-installers.git] / src / common / step / pkgmgr / step_check_force_clean.cc
1 // Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
2 // Use of this source code is governed by an apache 2.0 license that can be
3 // found in the LICENSE file.
4
5 #include "common/step/pkgmgr/step_check_force_clean.h"
6
7 #include <pkgmgr/pkgmgr_parser.h>
8 #include <pkgmgr-info.h>
9 #include <tzplatform_config.h>
10
11 #include <filesystem>
12
13 #include "common/utils/pkgmgr_query.h"
14 #include "common/installer_context.h"
15 #include "common/utils/manifest_util.h"
16
17 namespace fs = std::filesystem;
18
19
20 namespace common_installer {
21 namespace pkgmgr {
22
23 Step::Status StepCheckForceClean::process() {
24   if (context_->request_type.get() != RequestType::Uninstall &&
25       context_->request_type.get() != RequestType::PartialUninstall)
26     return Status::OK;
27
28   fs::path xml_path = GetManifestLocation(context_->pkgid.get(),
29                                           context_->uid.get(),
30                                           context_->is_readonly_package.get());
31
32   // if manifeset not found but pkg exist in db for target uid, do clean
33   PkgQueryInterface pkg_query(context_->pkgid.get(), context_->uid.get());
34   if (!fs::exists(xml_path) &&
35       pkg_query.IsPackageInstalled()) {
36     context_->force_clean_from_db.set(true);
37     manifest_x* manifest = PkgmgrGenerateManifestInfoFromDB(
38         context_->pkgid.get(), context_->uid.get());
39     if (!manifest) {
40       LOG(ERROR) << "Failed to get manifest_x from DB";
41       return Status::ERROR;
42     }
43
44     context_->manifest_data.set(manifest);
45   }
46
47   return Status::OK;
48 }
49
50 }  // namespace pkgmgr
51 }  // namespace common_installer