From a7f97820bd97175a1f54f336c9c8337158ce7fa1 Mon Sep 17 00:00:00 2001 From: Tomasz Iwanek Date: Fri, 4 Oct 2013 17:25:25 +0200 Subject: [PATCH] Widget gets corrupted if device battery is removed while uninstalling it. *** This patch is just a temporary fix. See [Remarks] section. *** [Issue#] WGL-580 [Problem] Uninstallation is broken if battery is removed when uninstalling. [Cause] Db is cleaned up but files are still present. [Solution] Ignore existing files for new installation. [Remarks] If widget was uninstalled (no db information). Source of problem is that installation/uninstalaltion is not fully transactional and there is no information that something is to be fixed. This is just a temporary fix. This is currently losing disc space for widgets that will not be installed again. Separate solution (daemon/boot time/...) for fixing unfinshed jobs should be proposed. [Verification] Build repo and (as in issue): 1) Install a heavy widget. 2) Uninstall the same the widget. 3) While uninstalling the widget, remove battery. 4) Again install the same widget.( on step 3, widget is un-installed) * Use widget attached in https://bugs.tizendev.org/jira/browse/WGL-580 Change-Id: I3e840cc5c508fe9951c77cabfceb377fb996a927 --- src/jobs/widget_install/task_configuration.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/jobs/widget_install/task_configuration.cpp b/src/jobs/widget_install/task_configuration.cpp index f584ff9..4dd66ca 100644 --- a/src/jobs/widget_install/task_configuration.cpp +++ b/src/jobs/widget_install/task_configuration.cpp @@ -63,6 +63,7 @@ const char* const OSP_MANIFEST_XML = "info/manifest.xml"; //allowed: a-z, A-Z, 0-9 const char* REG_TIZENID_PATTERN = "^[a-zA-Z0-9]{10}.{1,}$"; +const char* REG_PKGID_PATTERN = "^[a-zA-Z0-9]{10}$"; const char* REG_NAME_PATTERN = "^[a-zA-Z0-9._-]{1,}$"; const size_t PACKAGE_ID_LENGTH = 10; @@ -421,6 +422,7 @@ bool TaskConfiguration::validateTizenApplicationID( regex_t reg; if (regcomp(®, REG_TIZENID_PATTERN, REG_NOSUB | REG_EXTENDED) != 0) { _D("Regcomp failed"); + return false; } if (regexec(®, DPL::ToUTF8String(tizenAppId).c_str(), 0, NULL, 0) @@ -436,17 +438,20 @@ bool TaskConfiguration::validateTizenApplicationID( bool TaskConfiguration::validateTizenPackageID( const WrtDB::TizenPkgId &tizenPkgId) { - std::string pkgId = DPL::ToUTF8String(tizenPkgId); - - std::string installPath = - std::string(GlobalConfig::GetUserInstalledWidgetPath()) + - "/" + pkgId; + _D("tizen application ID = [%ls]", tizenPkgId.c_str()); - struct stat dirStat; - if ((stat(installPath.c_str(), &dirStat) == 0)) + regex_t reg; + if (regcomp(®, REG_PKGID_PATTERN, REG_NOSUB | REG_EXTENDED) != 0) { + _D("Regcomp failed"); return false; } + if (regexec(®, DPL::ToUTF8String(tizenPkgId).c_str(), 0, NULL, 0) == REG_NOMATCH) + { + regfree(®); + return false; + } + regfree(®); return true; } -- 2.7.4