[Release] wrt-installer_0.1.25
[framework/web/wrt-installer.git] / src / misc / widget_location.cpp
index d6fff67..8a080da 100644 (file)
@@ -28,8 +28,8 @@
 
 #include <widget_install/task_commons.h>
 
-WidgetLocation::DirectoryDeletor::DirectoryDeletor() :
-    m_dirpath(Jobs::WidgetInstall::createTempPath())
+WidgetLocation::DirectoryDeletor::DirectoryDeletor(bool isPreload) :
+    m_dirpath(Jobs::WidgetInstall::createTempPath(isPreload))
 {}
 
 WidgetLocation::DirectoryDeletor::DirectoryDeletor(std::string tempPath) :
@@ -67,13 +67,19 @@ WidgetLocation::WidgetLocation(const std::string & widgetname,
     m_pkgid(widgetname),
     m_widgetSource(sourcePath),
     m_type(t),
-    m_temp(new WidgetLocation::DirectoryDeletor())
+    m_temp(
+        new WidgetLocation::DirectoryDeletor(
+            INSTALL_LOCATION_TYPE_PRELOAD == locationType))
 {
     if (INSTALL_LOCATION_TYPE_PRELOAD == locationType) {
         m_installedPath += WrtDB::GlobalConfig::GetUserPreloadedWidgetPath();
     } else {
         m_installedPath += WrtDB::GlobalConfig::GetUserInstalledWidgetPath();
     }
+    // TODO clean-up
+    if (access(m_widgetSource.c_str(), F_OK) != 0) {
+        m_widgetSource = m_installedPath + "/" + m_pkgid;
+    }
 }
 
 WidgetLocation::WidgetLocation(const std::string & widgetname,
@@ -92,6 +98,10 @@ WidgetLocation::WidgetLocation(const std::string & widgetname,
     } else {
         m_installedPath += WrtDB::GlobalConfig::GetUserInstalledWidgetPath();
     }
+    // TODO clean-up
+    if (access(m_widgetSource.c_str(), F_OK) != 0) {
+        m_widgetSource = m_installedPath + "/" + m_pkgid;
+    }
 }
 
 // TODO cache all these paths