Fix uninstallation failure followed by https://tizendev.org/gerrit/#/c/85895/
authorSoyoung Kim <sy037.kim@samsung.com>
Fri, 6 Sep 2013 10:19:53 +0000 (19:19 +0900)
committerSoo-Hyun Choi <sh9.choi@samsung.com>
Fri, 6 Sep 2013 12:38:40 +0000 (21:38 +0900)
[Issue#]   N/A
[Problem]  Uninstall web app failure followed by:
           commit 04ed54303f1236635e13a0f0d7b99b2d8ebcf51f
[Cause]    DB operations were moved to just before removing files.
[Solution] Removing external file logic is moved to the DB operations.

[SCMRequest] N/A

Change-Id: Ie6b429c9815cac61212ad50ae6936428a5ac3b25

src/jobs/widget_uninstall/task_db_update.cpp
src/jobs/widget_uninstall/task_db_update.h
src/jobs/widget_uninstall/task_remove_files.cpp
src/jobs/widget_uninstall/task_remove_files.h

index ee4362c..a7c0d42 100644 (file)
@@ -25,6 +25,8 @@
 #include <widget_uninstall/job_widget_uninstall.h>
 #include <widget_uninstall/widget_uninstall_errors.h>
 #include <dpl/wrt-dao-ro/widget_dao_read_only.h>
+#include <dpl/utils/wrt_utility.h>
+#include <dpl/utils/path.h>
 #include <ace_api_install.h>
 #include <dpl/assert.h>
 #include <ace-common/ace_api_common.h>
@@ -38,6 +40,7 @@ TaskDbUpdate::TaskDbUpdate(UninstallerContext& context) :
     m_context(context)
 {
     AddStep(&TaskDbUpdate::StartStep);
+    AddStep(&TaskDbUpdate::StepRemoveExternalLocations);
     AddStep(&TaskDbUpdate::StepDbUpdate);
     AddStep(&TaskDbUpdate::StepLiveboxDBDelete);
     AddStep(&TaskDbUpdate::EndStep);
@@ -80,6 +83,40 @@ void TaskDbUpdate::StepLiveboxDBDelete()
     }
 }
 
+void TaskDbUpdate::StepRemoveExternalLocations()
+{
+    if (!m_context.removeAbnormal) {
+        WidgetDAO dao(DPL::FromUTF8String(m_context.tzAppid));
+        LogDebug("Removing external locations:");
+        WrtDB::ExternalLocationList externalPaths = dao.getWidgetExternalLocations();
+        FOREACH(file, externalPaths)
+        {
+            DPL::Utils::Path path(*file);
+            if(path.Exists()){
+                if(path.IsFile()){
+                    LogDebug("  -> " << path.Fullpath());
+                    Try{
+                        DPL::Utils::Remove(path);
+                    }Catch(DPL::Utils::Path::BaseException){
+                        LogError("Failed to remove the file: " << path.Fullpath());
+                    }
+                } else if (path.IsDir()){
+                    LogDebug("  -> " << path.Fullpath());
+                    Try{
+                        DPL::Utils::Remove(path);
+                    }Catch(DPL::Utils::Path::BaseException){
+                        Throw(Jobs::WidgetUninstall::TaskDbUpdate::
+                                Exception::RemoveFilesFailed);
+                    }
+                }
+            }else{
+                LogWarning("  -> " << path.Fullpath() << "(no such a path)");
+            }
+        }
+        dao.unregisterAllExternalLocations();
+    }
+}
+
 void TaskDbUpdate::StartStep()
 {
     LogDebug("--------- <TaskDbUpdate> : START ----------");
index 1d2b453..122b03f 100644 (file)
@@ -40,6 +40,7 @@ class TaskDbUpdate :
       public:
         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, DbStepFailed)
+        DECLARE_EXCEPTION_TYPE(Base, RemoveFilesFailed)
     };
 
     UninstallerContext& m_context;
@@ -47,6 +48,7 @@ class TaskDbUpdate :
   private:
     void StepDbUpdate();
     void StepLiveboxDBDelete();
+    void StepRemoveExternalLocations();
 
     void StartStep();
     void EndStep();
index ffdebda..c02f0a9 100644 (file)
@@ -47,7 +47,6 @@ TaskRemoveFiles::TaskRemoveFiles(UninstallerContext& context) :
 {
     AddStep(&TaskRemoveFiles::StartStep);
     AddStep(&TaskRemoveFiles::StepRemoveInstallationDirectory);
-    AddStep(&TaskRemoveFiles::StepRemoveExternalLocations);
     AddStep(&TaskRemoveFiles::StepRemoveFinished);
     AddStep(&TaskRemoveFiles::EndStep);
 }
@@ -110,40 +109,6 @@ void TaskRemoveFiles::StepRemoveFinished()
         "Widget remove steps Finished");
 }
 
-void TaskRemoveFiles::StepRemoveExternalLocations()
-{
-    if (!m_context.removeAbnormal) {
-        WidgetDAO dao(DPL::FromUTF8String(m_context.tzAppid));
-        LogDebug("Removing external locations:");
-        WrtDB::ExternalLocationList externalPaths = dao.getWidgetExternalLocations();
-        FOREACH(file, externalPaths)
-        {
-            DPL::Utils::Path path(*file);
-            if(path.Exists()){
-                if(path.IsFile()){
-                    LogDebug("  -> " << path.Fullpath());
-                    Try{
-                        DPL::Utils::Remove(path);
-                    }Catch(DPL::Utils::Path::BaseException){
-                        LogError("Failed to remove the file: " << path.Fullpath());
-                    }
-                } else if (path.IsDir()){
-                    LogDebug("  -> " << path.Fullpath());
-                    Try{
-                        DPL::Utils::Remove(path);
-                    }Catch(DPL::Utils::Path::BaseException){
-                        Throw(Jobs::WidgetUninstall::TaskRemoveFiles::
-                                Exception::RemoveFilesFailed);
-                    }
-                }
-            }else{
-                LogWarning("  -> " << path.Fullpath() << "(no such a path)");
-            }
-        }
-        dao.unregisterAllExternalLocations();
-    }
-}
-
 void TaskRemoveFiles::StartStep()
 {
     LogDebug("--------- <TaskRemoveFiles> : START ----------");
index c955435..276fb24 100644 (file)
@@ -48,7 +48,6 @@ class TaskRemoveFiles :
   private:
     void StepRemoveInstallationDirectory();
     void StepRemoveFinished();
-    void StepRemoveExternalLocations();
 
     void StartStep();
     void EndStep();