Fix wrong behavior related to keep_rwdata 33/123333/3
authorjongmyeongko <jongmyeong.ko@samsung.com>
Wed, 5 Apr 2017 07:59:19 +0000 (16:59 +0900)
committerjongmyeong ko <jongmyeong.ko@samsung.com>
Tue, 11 Apr 2017 06:09:11 +0000 (23:09 -0700)
if the request is for user app and keep_rwdata is on,
then we should not remove all contents of app.

Change-Id: I8eef5eb4acd48c2d44c9954fef41c7b373d07e7c
Signed-off-by: jongmyeongko <jongmyeong.ko@samsung.com>
src/common/step/filesystem/step_remove_files.cc

index 0a157bfd2f3df1fd9e9ebf6b2d6043ee1b322ff1..2786b9f9ce285553e427f5242c4f75ff08819e06 100644 (file)
@@ -68,8 +68,14 @@ Step::Status StepRemoveFiles::process() {
   if (context_->external_storage)
     context_->external_storage->Commit();
 
-  if (QueryIsPackageInstalled(context_->pkgid.get(), kGlobalUserUid) ||
-      context_->keep_rwdata.get()) {
+  bool is_keep_rwdata = false;
+  if (context_->request_mode.get() != RequestMode::GLOBAL) {
+    if (QueryIsPackageInstalled(context_->pkgid.get(), kGlobalUserUid) ||
+        context_->keep_rwdata.get())
+      is_keep_rwdata = true;
+  }
+
+  if (is_keep_rwdata) {
     for (bf::directory_iterator itr(pkg_path); itr != bf::directory_iterator();
         ++itr) {
       if (bf::is_directory(itr->status())) {
@@ -84,14 +90,6 @@ Step::Status StepRemoveFiles::process() {
       if (error)
         LOG(ERROR) << "Can't remove path:" << itr->path().c_str();
     }
-
-    if (context_->keep_rwdata.get()) {
-      bf::remove_all(pkg_path, error);
-      if (error)
-        LOG(ERROR) << "Can't remove directory:" <<
-            context_->pkg_path.get().c_str();
-    }
-
   } else {
     bf::remove_all(pkg_path, error);
     if (error)