[Release] wrt-installer_0.0.73
[framework/web/wrt-installer.git] / src / jobs / widget_install / task_recovery.cpp
index d6eba3d..1b922db 100644 (file)
@@ -34,7 +34,6 @@
 #include <dpl/foreach.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>
@@ -55,17 +54,19 @@ void TaskRecovery::StepCreateCheckFile()
 {
     LogInfo("Step: create information file for recovery");
 
-    std::string fileName;
-    size_t pos = m_context.widgetSource.rfind("/");
+    size_t pos = m_context.locations->getWidgetSource().rfind("/");
     std::ostringstream infoPath;
     infoPath << GlobalConfig::GetTempInstallInfoPath();
     infoPath << "/";
-    infoPath << m_context.widgetSource.substr(pos+1);
+    infoPath << m_context.locations->getWidgetSource().substr(pos+1);
 
     FILE *temp = fopen(infoPath.str().c_str(), "w+");
     if (temp != NULL) {
-        fputs(m_context.widgetSource.c_str(), temp);
-        fsync(temp->_fileno);
+        fputs(m_context.locations->getWidgetSource().c_str(), temp);
+        if (-1 == fsync(temp->_fileno)) {
+            fclose(temp);
+            ThrowMsg(Exceptions::InternalError, "Fail to fsync for recovery.");
+        }
         fclose(temp);
 
         m_context.installInfo = infoPath.str();