From 53857b853dba219a1fe184fca4f5c0f465482ab9 Mon Sep 17 00:00:00 2001 From: Soyoung Kim Date: Fri, 6 Sep 2013 19:19:53 +0900 Subject: [PATCH] Fix uninstallation failure followed by https://tizendev.org/gerrit/#/c/85895/ [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 | 37 +++++++++++++++++++++++++ src/jobs/widget_uninstall/task_db_update.h | 2 ++ src/jobs/widget_uninstall/task_remove_files.cpp | 35 ----------------------- src/jobs/widget_uninstall/task_remove_files.h | 1 - 4 files changed, 39 insertions(+), 36 deletions(-) diff --git a/src/jobs/widget_uninstall/task_db_update.cpp b/src/jobs/widget_uninstall/task_db_update.cpp index ee4362c..a7c0d42 100644 --- a/src/jobs/widget_uninstall/task_db_update.cpp +++ b/src/jobs/widget_uninstall/task_db_update.cpp @@ -25,6 +25,8 @@ #include #include #include +#include +#include #include #include #include @@ -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("--------- : START ----------"); diff --git a/src/jobs/widget_uninstall/task_db_update.h b/src/jobs/widget_uninstall/task_db_update.h index 1d2b453..122b03f 100644 --- a/src/jobs/widget_uninstall/task_db_update.h +++ b/src/jobs/widget_uninstall/task_db_update.h @@ -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(); diff --git a/src/jobs/widget_uninstall/task_remove_files.cpp b/src/jobs/widget_uninstall/task_remove_files.cpp index ffdebda..c02f0a9 100644 --- a/src/jobs/widget_uninstall/task_remove_files.cpp +++ b/src/jobs/widget_uninstall/task_remove_files.cpp @@ -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("--------- : START ----------"); diff --git a/src/jobs/widget_uninstall/task_remove_files.h b/src/jobs/widget_uninstall/task_remove_files.h index c955435..276fb24 100644 --- a/src/jobs/widget_uninstall/task_remove_files.h +++ b/src/jobs/widget_uninstall/task_remove_files.h @@ -48,7 +48,6 @@ class TaskRemoveFiles : private: void StepRemoveInstallationDirectory(); void StepRemoveFinished(); - void StepRemoveExternalLocations(); void StartStep(); void EndStep(); -- 2.7.4