Adjust moving storage directories - 'shared/' -> 'shared/res/' 48/60348/3
authorTomasz Iwanek <t.iwanek@samsung.com>
Thu, 25 Feb 2016 09:26:51 +0000 (10:26 +0100)
committerTomasz Iwanek <t.iwanek@samsung.com>
Thu, 3 Mar 2016 13:24:52 +0000 (14:24 +0100)
Requirement changed. We need to copy only 'shared/res/'.

To verify install, update, uninstall wgt package that
contains files in /shared/res/ and check if they were moved
properly to install location's shared/res/.

Change-Id: I20b8fcc174423ce74dcba5c9f6c116b1443f452e

src/wgt/step/step_wgt_patch_storage_directories.cc

index c6a7a94..e6f976e 100644 (file)
@@ -16,6 +16,7 @@ namespace bs = boost::system;
 namespace {
 
 const char kSharedLocation[] = "shared";
+const char kSharedResLocation[] = "shared/res";
 const char kResWgtSubPath[] = "res/wgt";
 const char kTemporaryData[] = "tmp";
 
@@ -39,8 +40,19 @@ common_installer::Step::Status StepWgtPatchStorageDirectories::process() {
 }
 
 bool StepWgtPatchStorageDirectories::ShareDirFor3x() {
-  bf::path src = context_->pkg_path.get() / kResWgtSubPath / kSharedLocation;
-  bf::path dst = context_->pkg_path.get() / kSharedLocation;
+  bf::path shared_dir = context_->pkg_path.get() / kSharedLocation;
+  if (!bf::exists(shared_dir)) {
+    bs::error_code error;
+    bf::create_directory(shared_dir);
+    if (error) {
+      LOG(ERROR) << "Failed to create directory: " << shared_dir;
+      return false;
+    }
+  }
+  bf::path src = context_->pkg_path.get() / kResWgtSubPath / kSharedResLocation;
+  if (!bf::exists(src))
+    return true;
+  bf::path dst = context_->pkg_path.get() / kSharedResLocation;
   if (!common_installer::MoveDir(src, dst,
                                  common_installer::FS_MERGE_DIRECTORIES)) {
     LOG(ERROR) << "Failed to move shared data from res/wgt to shared";