Revert "Add send signal if there is not enough memory during web app installation"
[framework/web/wrt-installer.git] / src / jobs / widget_install / widget_unzip.cpp
index 60bc464..d41b890 100644 (file)
@@ -25,9 +25,9 @@
 #include <widget_install/job_widget_install.h>
 #include <dpl/copy.h>
 #include <dpl/file_output.h>
+#include "dpl/utils/path.h"
 #include <dpl/abstract_waitable_input_adapter.h>
 #include <dpl/wrt-dao-ro/global_config.h>
-#include <task_commons.h>
 #include <sys/stat.h>
 #include <dlfcn.h>
 #include <installer_log.h>
@@ -106,7 +106,14 @@ void WidgetUnzip::unzipProgress(const std::string &destination)
         _D("Path to extract: %s", newPath.c_str());
 
         // Create path in case of it is empty
-        createTempPath(newPath);
+        Try
+        {
+            DPL::Utils::MakeDir(DPL::Utils::Path(newPath));
+        }
+        Catch(DPL::Utils::Path::BaseException)
+        {
+            ThrowMsg(Exceptions::FileOperationFailed, "Failed to create temporary directory");
+        }
     } else {
         // This is regular file
         std::string fileExtractPath = destination + "/" + fileName;
@@ -119,7 +126,14 @@ void WidgetUnzip::unzipProgress(const std::string &destination)
         _D("Path and file: %s : %s", pathAndFile.path.c_str(), pathAndFile.file.c_str());
 
         // First, ensure that path exists
-        createTempPath(pathAndFile.path);
+        Try
+        {
+            DPL::Utils::MakeDir(DPL::Utils::Path(pathAndFile.path));
+        }
+        Catch(DPL::Utils::Path::BaseException)
+        {
+            ThrowMsg(Exceptions::FileOperationFailed, "Failed to create temporary directory");
+        }
 
         Try
         {
@@ -158,11 +172,20 @@ bool WidgetUnzip::isDRMPackage(const std::string &source)
         return false;
     }
 
+    // clear existing error
+    dlerror();
+
     drm_oem_sapps_is_drm_file = reinterpret_cast <int (*)(const char*, int)>
         (dlsym(pHandle, "drm_oem_sapps_is_drm_file"));
-    pErrorMsg = dlerror();
-    if ((pErrorMsg != NULL) || (drm_oem_sapps_is_drm_file == NULL)) {
-        _E("dlopen failed : %s [%s]", source.c_str(), pErrorMsg);
+
+    if ((pErrorMsg = dlerror()) != NULL) {
+        _E("dlsym failed : %s [%s]", source.c_str(), pErrorMsg);
+        dlclose(pHandle);
+        return false;
+    }
+
+    if (drm_oem_sapps_is_drm_file == NULL) {
+        _E("drm_oem_sapps_is_drm_file is NULL : %s", source.c_str());
         dlclose(pHandle);
         return false;
     }
@@ -193,12 +216,21 @@ bool WidgetUnzip::decryptDRMPackage(const std::string &source, const std::string
         return false;
     }
 
+    // clear existing error
+    dlerror();
+
     drm_oem_sapps_decrypt_package = reinterpret_cast <int (*)(const char*, int,
             const char*, int)>
         (dlsym(pHandle, "drm_oem_sapps_decrypt_package"));
-    pErrorMsg = dlerror();
-    if ((pErrorMsg != NULL) || (drm_oem_sapps_decrypt_package == NULL)) {
-        _E("dlopen failed : %s [%s]", source.c_str(), pErrorMsg);
+
+    if ((pErrorMsg = dlerror()) != NULL) {
+        _E("dlsym failed : %s [%s]", source.c_str(), pErrorMsg);
+        dlclose(pHandle);
+        return false;
+    }
+
+    if (drm_oem_sapps_decrypt_package == NULL) {
+        _E("drm_oem_sapps_decrypt_package is NULL : %s", source.c_str());
         dlclose(pHandle);
         return false;
     }