Remove installed directory and manifest file when installation failed after ace check
authorSoyoung Kim <sy037.kim@samsung.com>
Fri, 21 Dec 2012 07:47:56 +0000 (16:47 +0900)
committerGerrit Code Review <gerrit2@kim11>
Wed, 26 Dec 2012 02:54:37 +0000 (11:54 +0900)
[Issue#] N/A
[Problem] unremoved installed directory and manifest file when installation failed.
[Cause] There aren't abort logic after ace check filed.
[Solution] Add abrot logic for remove
[SCMRequest] N/A

src/jobs/widget_install/task_file_manipulation.cpp
src/jobs/widget_install/task_manifest_file.cpp
src/jobs/widget_install/task_manifest_file.h

index 45e6224..b054e55 100644 (file)
@@ -265,19 +265,12 @@ void TaskFileManipulation::StepAbortRenamePath()
 {
     LogDebug("[Rename Widget Path] Aborting.... (Rename path)");
     std::string widgetPath;
-    if (m_context.widgetConfig.packagingType == PKG_TYPE_HYBRID_WEB_APP) {
+    if (m_context.widgetConfig.packagingType != PKG_TYPE_HYBRID_WEB_APP) {
         widgetPath = m_context.locations->getPackageInstallationDir();
-    } else {
-        widgetPath = m_context.locations->getSourceDir();
-    }
-    struct stat fileInfo;
-    if (stat(widgetPath.c_str(), &fileInfo) != 0) {
-        LogError("Failed to get widget file path : " << widgetPath);
-        return;
-    }
-
-    if (!(rename(widgetPath.c_str(), m_context.locations->getTemporaryPackageDir().c_str()) == 0)) {
-        LogError("Failed to rename");
+        if (!WrtUtilRemove(widgetPath)) {
+            ThrowMsg(Exceptions::RemovingFolderFailure,
+                    "Error occurs during removing existing folder");
+        }
     }
     LogDebug("Rename widget path sucessful!");
 }
index 908c698..21743d2 100755 (executable)
@@ -110,6 +110,8 @@ TaskManifestFile::TaskManifestFile(InstallerContext &inCont) :
         AddStep(&TaskManifestFile::stepGenerateManifest);
         AddStep(&TaskManifestFile::stepParseManifest);
         AddStep(&TaskManifestFile::stepFinalize);
+
+        AddAbortStep(&TaskManifestFile::stepAbortParseManifest);
     } else {
     // for widget update.
         AddStep(&TaskManifestFile::stepBackupIconFiles);
@@ -790,5 +792,25 @@ void TaskManifestFile::setAppCategory(UiApplication &uiApp)
     }
 }
 
+void TaskManifestFile::stepAbortParseManifest()
+{
+    LogError("[Parse Manifest] Abroting....");
+
+    int code = pkgmgr_parser_parse_manifest_for_uninstallation(
+            DPL::ToUTF8String(manifest_file).c_str(), NULL);
+
+    if (0 != code)
+    {
+        LogWarning("Manifest parser error: " << code);
+        ThrowMsg(ManifestParsingError, "Parser returncode: " << code);
+    }
+    int ret = unlink(DPL::ToUTF8String(manifest_file).c_str());
+    if (0 != ret)
+    {
+        LogWarning("No manifest file found: " << manifest_file);
+    }
+
+}
+
 } //namespace WidgetInstall
 } //namespace Jobs
index adffa7e..0755d6d 100644 (file)
@@ -68,6 +68,8 @@ class TaskManifestFile :
     void stepParseManifest();
     void stepParseUpgradedManifest();
 
+    void stepAbortParseManifest();
+
     //For widget update
     void stepBackupIconFiles();
     void stepUpdateFinalize();