Replace pkg_path with GetPkgPath() method in InstallerContext
[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 <boost/filesystem.hpp>
12 #include <boost/filesystem/path.hpp>
13
14 #include "common/pkgmgr_query.h"
15 #include "common/installer_context.h"
16 #include "common/utils/manifest_util.h"
17
18 namespace bf = boost::filesystem;
19
20
21 namespace common_installer {
22 namespace pkgmgr {
23
24 Step::Status StepCheckForceClean::process() {
25   if (context_->request_type.get() != RequestType::Uninstall &&
26       context_->request_type.get() != RequestType::PartialUninstall)
27     return Status::OK;
28
29   bf::path xml_path = GetManifestLocation(context_->pkgid.get(),
30                                           context_->uid.get(),
31                                           context_->is_readonly_package.get());
32
33   // if manifeset not found but pkg exist in db for target uid, do clean
34   PkgQueryInterface pkg_query(context_->pkgid.get(), context_->uid.get());
35   if (!bf::exists(xml_path) &&
36       pkg_query.IsPackageInstalled()) {
37     context_->force_clean_from_db.set(true);
38     manifest_x* manifest =
39         static_cast<manifest_x*>(calloc(1, sizeof(manifest_x)));
40     if (!PkgmgrGenerateManifestInfoFromDB(manifest, context_->pkgid.get(),
41             context_->uid.get())) {
42       context_->manifest_data.set(manifest);
43     }
44   }
45
46   return Status::OK;
47 }
48
49 }  // namespace pkgmgr
50 }  // namespace common_installer