Fix minor coding rule 27/218827/5
authorJunghyun Yeon <jungh.yeon@samsung.com>
Thu, 28 Nov 2019 10:05:14 +0000 (19:05 +0900)
committerJunghyun Yeon <jungh.yeon@samsung.com>
Wed, 22 Apr 2020 08:42:23 +0000 (08:42 +0000)
- Apply early-return policy.
- Print error while some boost API calling has failed.

Change-Id: I659e486fe6e7ed540497613470fa3c3a19d774e1
Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
src/tpk/step/configuration/step_check_reinstall_manifest.cc
src/tpk/step/filesystem/step_check_pkg_directory_path.cc
src/tpk/step/filesystem/step_create_tpk_symbolic_link.cc

index 22b13c95a46bb1eb421a2b2a6666e672c0914776..82bb073d42862d4745d1cf3d712ef3b23cb4dae4 100644 (file)
@@ -22,20 +22,22 @@ namespace configuration {
 
 common_installer::Step::Status StepCheckReinstallManifest::process() {
   bf::path target = context_->unpacked_dir_path.get() / kManifest;
-  if (!bf::exists(target)) {
-    bf::path source = context_->root_application_path.get() /
-        context_->pkgid.get() / kManifest;
-    if (!bf::exists(source)) {
-      LOG(ERROR) << "Cannot find old manifest file";
-      return Status::APP_DIR_ERROR;
-    }
-    bs::error_code error;
-    bf::copy_file(source, target, error);
-    if (error) {
-      LOG(ERROR) << "Failed to copy old manifest file";
-      return Status::APP_DIR_ERROR;
-    }
+  if (bf::exists(target))
+    return Status::OK;
+
+  bf::path source = context_->root_application_path.get() /
+      context_->pkgid.get() / kManifest;
+  if (!bf::exists(source)) {
+    LOG(ERROR) << "Cannot find old manifest file";
+    return Status::APP_DIR_ERROR;
   }
+  bs::error_code error;
+  bf::copy_file(source, target, error);
+  if (error) {
+    LOG(ERROR) << "Failed to copy old manifest file";
+    return Status::APP_DIR_ERROR;
+  }
+
   return Status::OK;
 }
 
index 04b564d151218f02708c3eb3c9ad8191831e5aaf..fc8dc30958220a6657b022b27cf04e81ad11f1ac 100644 (file)
@@ -14,18 +14,20 @@ namespace bf = boost::filesystem;
 namespace bs = boost::system;
 
 common_installer::Step::Status StepCheckPkgDirPath::process() {
-  if (!bf::exists(context_->GetPkgPath())) {
-    LOG(INFO) << "Create pkg_path("
-              << context_->GetPkgPath()
-              << ") for package("
-              << context_->pkgid.get() << ")";
-    bs::error_code error;
-    bf::create_directories(context_->GetPkgPath(), error);
-    if (error) {
-      LOG(ERROR) << "Cannot create directory: "
-                 << context_->GetPkgPath().string();
-      return Step::Status::APP_DIR_ERROR;
-    }
+  if (bf::exists(context_->GetPkgPath()))
+    return Status::OK;
+
+  LOG(INFO) << "Create pkg_path("
+            << context_->GetPkgPath()
+            << ") for package("
+            << context_->pkgid.get() << ")";
+  bs::error_code error;
+  bf::create_directories(context_->GetPkgPath(), error);
+  if (error) {
+    LOG(ERROR) << "Cannot create directory: "
+               << context_->GetPkgPath().string();
+               << ", error: " << error.what();
+    return Step::Status::APP_DIR_ERROR;
   }
 
   return Status::OK;
index 29f215815569ae50d136bb3d346ec545356d68a9..80ec9809127bee749df62eecd14be4d08a2d5ce4 100644 (file)
@@ -25,7 +25,7 @@ using common_installer::InstallerContext;
 typedef common_installer::Step::Status Status;
 
 bool CreateSymLink(application_x* app, InstallerContext* context) {
-  boost::system::error_code boost_error;
+
   bf::path bindir = context->GetPkgPath() /
       bf::path("bin");
   LOG(DEBUG) << "Creating dir: " << bindir;
@@ -35,20 +35,24 @@ bool CreateSymLink(application_x* app, InstallerContext* context) {
     return false;
   }
 
-  if (app->ui_gadget && strcmp(app->ui_gadget, "true") == 0) {
-    // Ug-client path
-    // Make a symlink with the name of appid, pointing /usr/bin/ug-client
-    bf::path app_exec_path(app->exec);
-    if (!bf::exists(app_exec_path)) {
-      bf::path ug_client_path(tzplatform_mkpath(TZ_SYS_BIN, "ug-client"));
-      LOG(INFO) << "Createing symlink " << app_exec_path << " pointing " <<
-        ug_client_path;
-      bf::create_symlink(ug_client_path, app_exec_path, boost_error);
-      if (boost_error) {
-        LOG(ERROR) << "Symlink creation failure: " << app_exec_path;
-        return false;
-      }
-    }
+  if (!app->ui_gadget || strcmp(app->ui_gadget, "true") != 0)
+    return true;
+
+  bf::path app_exec_path(app->exec);
+  if (bf::exists(app_exec_path))
+    return true;
+
+  // Ug-client path
+  // Make a symlink with the name of appid, pointing /usr/bin/ug-client
+  bf::path ug_client_path(tzplatform_mkpath(TZ_SYS_BIN, "ug-client"));
+  LOG(INFO) << "Createing symlink " << app_exec_path << " pointing " <<
+    ug_client_path;
+  boost::system::error_code error;
+  bf::create_symlink(ug_client_path, app_exec_path, error);
+  if (error) {
+    LOG(ERROR) << "Symlink creation failure: " << app_exec_path
+                << ", error :" << error.what();
+    return false;
   }
 
   return true;