Remove rw directories when request mode is global 81/115581/5
authorDamian Pietruchowski <d.pietruchow@samsung.com>
Mon, 20 Feb 2017 11:32:44 +0000 (12:32 +0100)
committerjongmyeong ko <jongmyeong.ko@samsung.com>
Tue, 2 May 2017 11:19:26 +0000 (11:19 +0000)
Runtime rw directories should be removed in update for
global request mode.

Change-Id: If9d6c095a91284937b461ae9b60446dbfdcad720
Signed-off-by: Damian Pietruchowski <d.pietruchow@samsung.com>
src/common/step/filesystem/step_copy_storage_directories.cc
src/common/step/filesystem/step_copy_storage_directories.h

index c7c1ff3..2462a7c 100644 (file)
@@ -20,6 +20,9 @@ namespace {
 const char kCache[] = "cache";
 const char kDataLocation[] = "data";
 const char kSharedResLocation[] = "shared";
+const char kSharedCache[] = "shared/cache";
+const char kSharedData[] = "shared/data";
+const char kSharedTrusted[] = "shared/trusted";
 
 }  // namespace
 
@@ -52,8 +55,11 @@ common_installer::Step::Status StepCopyStorageDirectories::precheck() {
 }
 
 common_installer::Step::Status StepCopyStorageDirectories::process() {
-  if (context_->request_mode.get() == RequestMode::GLOBAL)
+  if (context_->request_mode.get() == RequestMode::GLOBAL) {
+    RemoveAll();
     return Status::OK;
+  }
+
   if (!MoveAppStorage(backup_path_,
                       context_->pkg_path.get(),
                       kDataLocation, true)) {
@@ -106,5 +112,20 @@ bool StepCopyStorageDirectories::CacheDir() {
   return true;
 }
 
+void StepCopyStorageDirectories::RemoveAll() {
+  bs::error_code error_code;
+  bf::path data_path = context_->pkg_path.get() / kDataLocation;
+  bf::path cache_path = context_->pkg_path.get() / kCache;
+  bf::path shared_data_path = context_->pkg_path.get() / kSharedData;
+  bf::path shared_cache_path = context_->pkg_path.get() / kSharedCache;
+  bf::path shared_trusted_path = context_->pkg_path.get() / kSharedTrusted;
+
+  bf::remove_all(data_path, error_code);
+  bf::remove_all(cache_path, error_code);
+  bf::remove_all(shared_data_path, error_code);
+  bf::remove_all(shared_cache_path, error_code);
+  bf::remove_all(shared_trusted_path, error_code);
+}
+
 }  // namespace filesystem
 }  // namespace common_installer
index dafd04b..abbbcf8 100644 (file)
@@ -50,6 +50,7 @@ class StepCopyStorageDirectories : public common_installer::Step {
                       const boost::filesystem::path& in_dst,
                       const char *key, bool merge_dirs = false);
   bool CacheDir();
+  void RemoveAll();
   boost::filesystem::path backup_path_;
   STEP_NAME(CopyStorageDirectories)
 };