[Release] wrt-installer_0.0.73
[framework/web/wrt-installer.git] / src / jobs / widget_install / task_private_storage.cpp
index b88211c..8d9934f 100644 (file)
@@ -33,7 +33,7 @@
 #include <dpl/errno_string.h>
 
 #include <dpl/wrt-dao-ro/widget_config.h>
-#include <dpl/utils/file_utils.h>
+#include <dpl/utils/wrt_utility.h>
 #include <widget_install/job_widget_install.h>
 #include <widget_install/widget_install_context.h>
 #include <widget_install/widget_install_errors.h>
@@ -66,13 +66,12 @@ void TaskPrivateStorage::StepCreateDirectory()
     std::ostringstream widgetPath;
     DPL::OptionalString pkgname = m_context.widgetConfig.pkgname;
     if(!pkgname.IsNull()) {
-        widgetPath << GlobalConfig::GetUserInstalledWidgetPath() << "/";
-        widgetPath << pkgname << "/";
+        widgetPath << m_context.locations->getPackageInstallationDir() << "/";
     } else {
         ThrowMsg(Exceptions::InternalError, "No Package name exists.");
     }
 
-    if (access(widgetPath.str().c_str(), W_OK | X_OK) != 0) {
+    if (euidaccess(widgetPath.str().c_str(), W_OK | X_OK) != 0) {
         ThrowMsg(Exceptions::InternalError, DPL::GetErrnoString());
     }
 
@@ -80,8 +79,12 @@ void TaskPrivateStorage::StepCreateDirectory()
     storagePath << widgetPath.str().c_str()
                 << GlobalConfig::GetWidgetPrivateStoragePath();
 
-    if (access(storagePath.str().c_str(), F_OK) != 0) {
-        FileUtils::MakePath(storagePath.str(), PRIVATE_STORAGE_MODE);
+    if (euidaccess(storagePath.str().c_str(), F_OK) != 0) {
+        if(!WrtUtilMakeDir(storagePath.str(), PRIVATE_STORAGE_MODE)){
+            LogError("Failed to create directory for private storage");
+            ThrowMsg(Exceptions::InternalError,
+                    "Failed to create directory for private storage");
+        }
         // '5000' is default uid, gid for applications.
         // So installed applications should be launched as process of uid '5000'.
         // the process can access private directory 'data' of itself.
@@ -92,7 +95,7 @@ void TaskPrivateStorage::StepCreateDirectory()
             ThrowMsg(Exceptions::InternalError,
                  "Chown to invaild user");
         }
-    } else if (access(storagePath.str().c_str(), W_OK | R_OK | X_OK) == 0) {
+    } else if (euidaccess(storagePath.str().c_str(), W_OK | R_OK | X_OK) == 0) {
         LogInfo("Private storage already exists.");
         // Even if private directory already is created, private dircetory
         // should change owner.