Fix double parsing of config.xml in delta wgt mode 40/86940/6
authorBartlomiej Kunikowski <b.kunikowski@partner.samsung.com>
Mon, 5 Sep 2016 13:29:49 +0000 (15:29 +0200)
committerBartlomiej Kunikowski <b.kunikowski@partner.samsung.com>
Tue, 6 Sep 2016 08:25:32 +0000 (10:25 +0200)
Fixed by add a optional delay in checking existence of start files
and adding new step

Requires:
 - https://review.tizen.org/gerrit/#/c/86941/

Change-Id: I9efed825d5f04af28493a6bd0003e3b9d6efb3c8

src/wgt/CMakeLists.txt
src/wgt/step/configuration/step_check_start_files.cc [new file with mode: 0644]
src/wgt/step/configuration/step_check_start_files.h [new file with mode: 0644]
src/wgt/step/configuration/step_parse.cc
src/wgt/wgt_backend_data.h
src/wgt/wgt_installer.cc

index fece9b1..3124963 100755 (executable)
@@ -1,5 +1,6 @@
 # Target - sources
 SET(SRCS
+  step/configuration/step_check_start_files.cc
   step/configuration/step_parse.cc
   step/encryption/step_encrypt_resources.cc
   step/encryption/step_remove_encryption_data.cc
diff --git a/src/wgt/step/configuration/step_check_start_files.cc b/src/wgt/step/configuration/step_check_start_files.cc
new file mode 100644 (file)
index 0000000..7bf3ad6
--- /dev/null
@@ -0,0 +1,48 @@
+// Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by a apache 2.0 license that can be
+// found in the LICENSE file.
+
+#include "wgt/step/configuration/step_check_start_files.h"
+
+#include <boost/filesystem/path.hpp>
+
+#include <common/app_installer.h>
+#include <common/installer_context.h>
+#include <common/step/step.h>
+
+#include <wgt/wgt_backend_data.h>
+
+#include <wgt_manifest_handlers/w3c_pc_utils.h>
+#include <wgt_manifest_handlers/content_handler.h>
+
+namespace bf = boost::filesystem;
+
+namespace wgt {
+namespace configuration {
+
+common_installer::Step::Status StepCheckStartFiles::process() {
+  bool flag = false;  // it's not important in this step to use this flag
+  std::string error;
+  bool result_check = CheckStartFile(static_cast<WgtBackendData*>
+      (context_->backend_data.get())->content.get(),
+      context_->unpacked_dir_path.get(),
+      &flag);
+  if (!result_check) {
+    LOG(ERROR) << "Could not find valid start file";
+    return common_installer::Step::Status::PARSE_ERROR;
+  }
+
+  result_check = CheckServicesStartFiles(static_cast<WgtBackendData*>(
+      context_->backend_data.get())->service_list.get(),
+      context_->unpacked_dir_path.get(),
+      &error);
+  if (!result_check) {
+    LOG(ERROR) << error;
+    return common_installer::Step::Status::PARSE_ERROR;
+  }
+
+  return common_installer::Step::Status::OK;
+}
+
+}  // namespace configuration
+}  // namespace wgt
diff --git a/src/wgt/step/configuration/step_check_start_files.h b/src/wgt/step/configuration/step_check_start_files.h
new file mode 100644 (file)
index 0000000..7fc7025
--- /dev/null
@@ -0,0 +1,48 @@
+// Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by a apache 2.0 license that can be
+// found in the LICENSE file.
+#ifndef WGT_STEP_CONFIGURATION_STEP_CHECK_START_FILES_H_
+#define WGT_STEP_CONFIGURATION_STEP_CHECK_START_FILES_H_
+
+#include <boost/filesystem.hpp>
+
+#include <common/app_installer.h>
+#include <common/installer_context.h>
+#include <common/step/step.h>
+
+#include <manifest_parser/utils/logging.h>
+
+#include <wgt/wgt_backend_data.h>
+
+#include <type_traits>
+#include <cassert>
+#include <memory>
+#include <set>
+#include <string>
+
+namespace wgt {
+namespace configuration {
+
+/**
+ * \brief The StepCheckStartFiles class
+ *        Checks if valid start files exists.
+ *        It needs content info from wgt_backend_data.
+ *
+ * Step is used in delta mode.
+ */
+class StepCheckStartFiles : public common_installer::Step {
+ public:
+  using Step::Step;
+
+  Status process() override;
+  Status clean() override { return Status::OK; }
+  Status undo() override { return Status::OK; }
+  Status precheck() override { return Status::OK; }
+
+  STEP_NAME(CheckStartFiles)
+};
+
+}  // namespace configuration
+}  // namespace wgt
+
+#endif  // WGT_STEP_CONFIGURATION_STEP_CHECK_START_FILES_H_
index b2a12bf..0218240 100644 (file)
@@ -650,15 +650,31 @@ common_installer::Step::Status StepParse::process() {
     LOG(ERROR) << "[Parse] Parse failed. " <<  parser_->GetErrorMessage();
     return common_installer::Step::Status::PARSE_ERROR;
   }
+
+  WgtBackendData* backend_data =
+    static_cast<WgtBackendData*>(context_->backend_data.get());
+
   if (check_start_file_) {
-    if (!parser_->HasValidStartFile()) {
+    if (!parser_->CheckValidStartFile()) {
       LOG(ERROR) << parser_->GetErrorMessage();
       return common_installer::Step::Status::PARSE_ERROR;
     }
-    if (!parser_->HasValidServicesStartFiles()) {
+    if (!parser_->CheckValidServicesStartFiles()) {
       LOG(ERROR) << parser_->GetErrorMessage();
       return common_installer::Step::Status::PARSE_ERROR;
     }
+  } else {
+    // making backup of content data and services content data
+    auto content_info =
+      GetManifestDataForKey<const wgt::parse::ContentInfo>(
+              wgt::application_widget_keys::kTizenContentKey);
+    auto service_list =
+      GetManifestDataForKey<const wgt::parse::ServiceList>(
+              wgt::application_widget_keys::kTizenServiceKey);
+    if (content_info)
+      backend_data->content.set(*content_info);
+    if (service_list)
+      backend_data->service_list.set(*service_list);
   }
 
   manifest_x* manifest =
@@ -711,9 +727,6 @@ common_installer::Step::Status StepParse::process() {
   if (perm_info)
      permissions = perm_info->GetAPIPermissions();
 
-  WgtBackendData* backend_data =
-      static_cast<WgtBackendData*>(context_->backend_data.get());
-
   auto settings_info =
       GetManifestDataForKey<const wgt::parse::SettingInfo>(
               wgt::application_widget_keys::kTizenSettingKey);
@@ -736,7 +749,6 @@ common_installer::Step::Status StepParse::process() {
   LOG(DEBUG) << "  ]-";
   LOG(DEBUG) << "]-";
 
-  // TODO(t.iwanek): In delta mode this step is running two times
   if (context_->manifest_data.get())
     pkgmgr_parser_free_manifest_xml(context_->manifest_data.get());
 
index 3d2791d..c36cbad 100644 (file)
@@ -9,6 +9,8 @@
 #include <common/utils/property.h>
 
 #include <wgt_manifest_handlers/appwidget_handler.h>
+#include <wgt_manifest_handlers/content_handler.h>
+#include <wgt_manifest_handlers/service_handler.h>
 #include <wgt_manifest_handlers/setting_handler.h>
 
 #include <string>
@@ -28,6 +30,8 @@ class WgtBackendData : public common_installer::BackendData {
   Property<parse::SettingInfo> settings;
 
   Property<parse::AppWidgetInfo> appwidgets;
+  Property<parse::ContentInfo> content;
+  Property<parse::ServiceList> service_list;
 };
 
 }  // namespace wgt
index b728742..282b3c0 100755 (executable)
@@ -72,6 +72,7 @@
 #include <common/step/rds/step_rds_modify.h>
 #include <common/step/rds/step_rds_parse.h>
 
+#include "wgt/step/configuration/step_check_start_files.h"
 #include "wgt/step/configuration/step_parse.h"
 #include "wgt/step/encryption/step_encrypt_resources.h"
 #include "wgt/step/encryption/step_remove_encryption_data.h"
@@ -233,10 +234,8 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr)
     case ci::RequestType::Delta: {
       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
       AddStep<ci::filesystem::StepUnzip>();
-      // TODO(t.iwanek): manifest is parsed twice...
       AddStep<wgt::configuration::StepParse>(
             wgt::configuration::StepParse::ConfigLocation::PACKAGE, false);
-      // start file may not have changed
       AddStep<ci::configuration::StepParseManifest>(
           ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
           ci::configuration::StepParseManifest::StoreLocation::BACKUP);
@@ -244,8 +243,7 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr)
       AddStep<ci::filesystem::StepEnableExternalMount>();
       AddStep<ci::filesystem::StepDeltaPatch>("res/wgt/");
       AddStep<ci::filesystem::StepDisableExternalMount>();
-      AddStep<wgt::configuration::StepParse>(
-          wgt::configuration::StepParse::ConfigLocation::PACKAGE, true);
+      AddStep<wgt::configuration::StepCheckStartFiles>();
       AddStep<ci::security::StepCheckSignature>();
       AddStep<ci::security::StepPrivilegeCompatibility>();
       AddStep<wgt::security::StepCheckSettingsLevel>();