From 2585733fb42fd4b83fbf6162018ad118cb3e0335 Mon Sep 17 00:00:00 2001 From: Tomasz Iwanek Date: Fri, 29 May 2015 15:50:42 +0200 Subject: [PATCH] Cleanup - GetBackupPathForPackagePath Backup directory in update installation is created per package not per application (becuase we just copy whole content). There should be one place which defines how this path is constructed. Change-Id: I694d4641088acbeccd0cdab04d9e510b16415bf1 --- src/common/context_installer.cc | 7 +++++++ src/common/context_installer.h | 3 +++ src/common/step/step_copy_backup.cc | 3 +-- src/common/step/step_copy_storage_directories.cc | 4 ++-- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/common/context_installer.cc b/src/common/context_installer.cc index 6e9d434..7007083 100644 --- a/src/common/context_installer.cc +++ b/src/common/context_installer.cc @@ -26,4 +26,11 @@ ContextInstaller::~ContextInstaller() { delete backend_data.get(); } +boost::filesystem::path GetBackupPathForPackagePath( + const boost::filesystem::path& pkg_path) { + fs::path backup_path = pkg_path; + backup_path += ".bck"; + return backup_path; +} + } // namespace common_installer diff --git a/src/common/context_installer.h b/src/common/context_installer.h index b11b483..ae01c48 100644 --- a/src/common/context_installer.h +++ b/src/common/context_installer.h @@ -83,6 +83,9 @@ class ContextInstaller { Property backend_data; }; +boost::filesystem::path GetBackupPathForPackagePath( + const boost::filesystem::path& pkg_path); + } // namespace common_installer #endif // COMMON_CONTEXT_INSTALLER_H_ diff --git a/src/common/step/step_copy_backup.cc b/src/common/step/step_copy_backup.cc index fb3b71a..62777b9 100644 --- a/src/common/step/step_copy_backup.cc +++ b/src/common/step/step_copy_backup.cc @@ -37,8 +37,7 @@ Step::Status StepCopyBackup::process() { !m->uiapplication)) install_path_ /= bf::path(context_->manifest_data.get()->mainapp_id); - backup_path_ = context_->pkg_path.get(); - backup_path_ += ".bck"; + backup_path_ = GetBackupPathForPackagePath(context_->pkg_path.get()); // backup old content if (!utils::MoveDir(context_->pkg_path.get(), backup_path_)) { diff --git a/src/common/step/step_copy_storage_directories.cc b/src/common/step/step_copy_storage_directories.cc index 50fa4ff..a2817b6 100644 --- a/src/common/step/step_copy_storage_directories.cc +++ b/src/common/step/step_copy_storage_directories.cc @@ -20,8 +20,8 @@ const char kDataLocation[] = "data"; const char kSharedLocation[] = "shared"; bool RestoreApplicationStorageForData(const bf::path& pkg_path) { - bf::path backup_path = pkg_path; - backup_path += ".bck"; + bf::path backup_path = + common_installer::GetBackupPathForPackagePath(pkg_path); bs::error_code error_code; if (!bf::exists(backup_path, error_code)) { -- 2.7.4