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.
5 #include "common/step/pkgmgr/step_check_force_clean.h"
7 #include <pkgmgr/pkgmgr_parser.h>
8 #include <pkgmgr-info.h>
9 #include <tzplatform_config.h>
11 #include <boost/filesystem.hpp>
12 #include <boost/filesystem/path.hpp>
14 #include "common/utils/pkgmgr_query.h"
15 #include "common/installer_context.h"
16 #include "common/utils/manifest_util.h"
18 namespace bf = boost::filesystem;
21 namespace common_installer {
24 Step::Status StepCheckForceClean::process() {
25 if (context_->request_type.get() != RequestType::Uninstall &&
26 context_->request_type.get() != RequestType::PartialUninstall)
29 bf::path xml_path = GetManifestLocation(context_->pkgid.get(),
31 context_->is_readonly_package.get());
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 = PkgmgrGenerateManifestInfoFromDB(
39 context_->pkgid.get(), context_->uid.get());
41 LOG(ERROR) << "Failed to get manifest_x from DB";
45 context_->manifest_data.set(manifest);
52 } // namespace common_installer