1 // Copyright (c) 2015 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/filesystem/step_recover_storage_directories.h"
7 #include <boost/filesystem/path.hpp>
8 #include <boost/system/error_code.hpp>
10 #include "common/paths.h"
11 #include "common/utils/file_util.h"
15 const char kDataLocation[] = "data";
16 const char kSharedResLocation[] = "shared";
20 namespace bf = boost::filesystem;
22 namespace common_installer {
23 namespace filesystem {
25 bool StepRecoverStorageDirectories::MoveAppStorage(
26 const bf::path& in_src,
27 const bf::path& in_dst,
29 bf::path src = in_src / key;
32 bf::path dst = in_dst / key;
33 return common_installer::MoveDir(src, dst, FS_MERGE_SKIP);
36 Step::Status StepRecoverStorageDirectories::RecoveryUpdate() {
37 if (!context_->pkg_path.get().empty()) {
38 bf::path backup_path = common_installer::GetBackupPathForPackagePath(
39 context_->pkg_path.get());
40 if (bf::exists(backup_path)) {
41 MoveAppStorage(context_->pkg_path.get(), backup_path, kDataLocation);
42 MoveAppStorage(context_->pkg_path.get(), backup_path, kSharedResLocation);
48 Step::Status StepRecoverStorageDirectories::RecoveryMountUpdate() {
52 } // namespace filesystem
53 } // namespace common_installer