Fix RDS when no start file is updated 00/45900/6
authorTomasz Iwanek <t.iwanek@samsung.com>
Mon, 10 Aug 2015 06:48:11 +0000 (08:48 +0200)
committerPawel Sikorski <p.sikorski@samsung.com>
Tue, 18 Aug 2015 16:17:15 +0000 (09:17 -0700)
RDS failed to work when start file was not updated
due to switch to WidgetConfigParser that has additional
filesystem checks for start file.

StepParse has flags_ parameter now to prevent RDS from
failing when start file is localized.

Fixed backup path of files.

Requeries submit of: https://review.tizen.org/gerrit/#/c/45895/

Change-Id: I129a5face58c51324de0fd774c39008cceac86f0

src/wgt/step/step_parse.cc
src/wgt/step/step_parse.h
src/wgt/step/step_parse_recovery.cc
src/wgt/step/step_parse_recovery.h
src/wgt/step/step_rds_modify.cc
src/wgt/wgt_installer.cc

index 00db36f..55694a1 100755 (executable)
@@ -58,6 +58,12 @@ namespace parse {
 namespace app_keys = wgt::application_widget_keys;
 namespace manifest_keys = wgt::application_manifest_keys;
 
+StepParse::StepParse(common_installer::ContextInstaller* context,
+                     bool check_start_file)
+    : Step(context),
+      check_start_file_(check_start_file) {
+}
+
 std::set<std::string> StepParse::ExtractPrivileges(
     std::shared_ptr<const PermissionsInfo> perm_info) const {
   return perm_info->GetAPIPermissions();
@@ -289,6 +295,12 @@ common_installer::Step::Status StepParse::process() {
     LOG(ERROR) << "[Parse] Parse failed. " <<  parser_->GetErrorMessage();
     return common_installer::Step::Status::ERROR;
   }
+  if (check_start_file_) {
+    if (!parser_->HasValidStartFile()) {
+      LOG(ERROR) << "No valid start file" <<  parser_->GetErrorMessage();
+      return common_installer::Step::Status::ERROR;
+    }
+  }
 
   const manifest_x* manifest = context_->manifest_data.get();
   if (!FillManifestX(const_cast<manifest_x*>(manifest))) {
index 0c2a37e..b0b4d49 100644 (file)
@@ -23,7 +23,8 @@ namespace parse {
 
 class StepParse : public common_installer::Step {
  public:
-  using Step::Step;
+  explicit StepParse(common_installer::ContextInstaller* context,
+      bool check_start_file);
 
   Status process() override;
   Status clean() override { return Status::OK; }
@@ -53,6 +54,7 @@ class StepParse : public common_installer::Step {
   bool FillManifestX(manifest_x* manifest);
 
   std::unique_ptr<wgt::parse::WidgetConfigParser> parser_;
+  bool check_start_file_;
 
   SCOPE_LOG_TAG(Parse)
 };
index 44dd715..9ec6306 100644 (file)
@@ -16,6 +16,11 @@ const char kResWgtPath[] = "res/wgt";
 namespace wgt {
 namespace parse {
 
+StepParseRecovery::StepParseRecovery(
+    common_installer::ContextInstaller* context)
+    : StepParse(context, false) {
+}
+
 common_installer::Step::Status StepParseRecovery::process() {
   (void) StepParse::process();
   return Status::OK;
index 8d7db7c..a117452 100644 (file)
@@ -24,7 +24,7 @@ namespace parse {
  */
 class StepParseRecovery : public StepParse {
  public:
-  using StepParse::StepParse;
+  StepParseRecovery(common_installer::ContextInstaller* context);
 
   Status process() override;
   Status precheck() override;
index c8550c5..2204497 100644 (file)
@@ -164,8 +164,7 @@ bool StepRDSModify::PerformBackup(std::string relative_path,
   if (backup_temp_dir_.empty())
     return false;
   if (operation == Operation::DELETE || operation == Operation::MODIFY) {
-    bf::path app_path = context_->pkg_path.get() /
-        context_->manifest_data.get()->mainapp_id;;
+    bf::path app_path = context_->pkg_path.get() / "res" / "wgt";
     bf::path source_path = app_path  / relative_path;
     if (bf::is_directory(source_path)) {
       if (!cu::CreateDir(backup_temp_dir_ / relative_path)) {
@@ -182,7 +181,8 @@ bool StepRDSModify::PerformBackup(std::string relative_path,
       }
       bf::copy_file(source_path, tmp_dest_path, error);
       if (error) {
-        LOG(ERROR) << "unable to backup file " << error.message();
+        LOG(ERROR) << "unable to backup file: "
+                   << source_path << " : " << error.message();
         return false;
       }
     }
index e6d881c..9b75632 100644 (file)
@@ -4,6 +4,8 @@
 
 #include "wgt/wgt_installer.h"
 
+#include <manifest_handlers/widget_config_parser.h>
+
 #include "common/pkgmgr_interface.h"
 #include "common/step/step_configure.h"
 #include "common/step/step_backup_manifest.h"
@@ -58,7 +60,7 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr)
     case ci::RequestType::Install : {
       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
       AddStep<ci::filesystem::StepUnzip>();
-      AddStep<wgt::parse::StepParse>();
+      AddStep<wgt::parse::StepParse>(true);
       AddStep<ci::security::StepCheckSignature>();
       AddStep<wgt::security::StepCheckSettingsLevel>();
       AddStep<wgt::filesystem::StepWgtResourceDirectory>();
@@ -74,7 +76,7 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr)
     case ci::RequestType::Update: {
       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
       AddStep<ci::filesystem::StepUnzip>();
-      AddStep<wgt::parse::StepParse>();
+      AddStep<wgt::parse::StepParse>(true);
       AddStep<ci::security::StepCheckSignature>();
       AddStep<wgt::security::StepCheckSettingsLevel>();
       AddStep<ci::security::StepCheckOldCertificate>();
@@ -104,7 +106,7 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr)
     }
     case ci::RequestType::Reinstall: {
       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
-      AddStep<wgt::parse::StepParse>();
+      AddStep<wgt::parse::StepParse>(false);
       AddStep<ci::backup::StepOldManifest>();
       AddStep<wgt::rds::StepRDSParse>();
       AddStep<wgt::rds::StepRDSModify>();