Stop using pkgdir-tool for directory operation 64/100364/1
authorJunghyun Yeon <jungh.yeon@samsung.com>
Mon, 28 Nov 2016 02:41:38 +0000 (11:41 +0900)
committerJunghyun Yeon <jungh.yeon@samsung.com>
Mon, 28 Nov 2016 02:41:38 +0000 (11:41 +0900)
- Backend has cap itself so another tool dedicated to directory operation
is no more needed
- Adjust order of including header for coding style

Change-Id: Ie86d253303e1a013400ba6dcc5b5e38bae2f2c3d
Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
src/tpk/external_dirs.cc
src/tpk/step/filesystem/step_create_external_storage_directories.cc

index ac79c33..0a07126 100644 (file)
@@ -4,7 +4,6 @@
 
 #include "tpk/external_dirs.h"
 
-#include <common/pkgdir_tool_request.h>
 #include <common/privileges.h>
 #include <common/pkgmgr_query.h>
 #include <common/shared_dirs.h>
@@ -33,16 +32,17 @@ bool CreateExternalAppdataDirectories(const std::string& pkgid,
   switch (request_mode) {
     case ci::RequestMode::GLOBAL: {
       LOG(DEBUG) << "Creating external directories for all users";
-      ci::RequestCreateExternalDirectories(pkgid);
-      break;
+      return ci::PerformExternalDirectoryCreationForAllUsers(pkgid);
     }
     case ci::RequestMode::USER: {
       LOG(DEBUG) << "Creating external directories for user: " << uid;
-      ci::PerformExternalDirectoryCreationForUser(uid, pkgid);
-      break;
+      return ci::PerformExternalDirectoryCreationForUser(uid, pkgid);
+    }
+    default: {
+      LOG(ERROR) << "UNexpected request mode";
+      return false;
     }
   }
-  return true;
 }
 
 bool DeleteExternalAppdataDirectories(const std::string& pkgid,
@@ -50,8 +50,7 @@ bool DeleteExternalAppdataDirectories(const std::string& pkgid,
   switch (request_mode) {
     case ci::RequestMode::GLOBAL: {
       LOG(DEBUG) << "Removing external directories for all users";
-      ci::RequestDeleteExternalDirectories(pkgid);
-      break;
+      return ci::PerformExternalDirectoryDeletionForAllUsers(pkgid);
     }
     case ci::RequestMode::USER: {
       // if package is globally installed, leave directories
@@ -59,11 +58,13 @@ bool DeleteExternalAppdataDirectories(const std::string& pkgid,
         return true;
 
       LOG(DEBUG) << "Removing external directories for user: " << uid;
-      ci::PerformExternalDirectoryDeletionForUser(uid, pkgid);
-      break;
+      return ci::PerformExternalDirectoryDeletionForUser(uid, pkgid);
+    }
+    default: {
+      LOG(ERROR) << "Unexpected request mode";
+      return false;
     }
   }
-  return true;
 }
 
 }  // namespace tpk
index bbe3d5c..2cdf090 100644 (file)
@@ -22,11 +22,13 @@ ci::Step::Status StepCreateExternalStorageDirectories::process() {
   if (!HasExternalAppdataPrivilege(context_->manifest_data.get())) {
     LOG(DEBUG) << "External storage privilege not found, skipping.";
     return Status::OK;
-  } else {
-    if (!CreateExternalAppdataDirectories(context_->pkgid.get(),
-                                          context_->request_mode.get(),
-                                          context_->uid.get()))
-      return Status::APP_DIR_ERROR;
+  }
+
+  if (!CreateExternalAppdataDirectories(context_->pkgid.get(),
+                                        context_->request_mode.get(),
+                                        context_->uid.get())) {
+    LOG(ERROR) << "Failed to create external appdata directories";
+    return Status::APP_DIR_ERROR;
   }
   return Status::OK;
 }