Fix StepRecoverExternalStorage 01/98201/5
authorPiotr Ganicz <p.ganicz@samsung.com>
Mon, 14 Nov 2016 15:35:01 +0000 (16:35 +0100)
committerjongmyeong ko <jongmyeong.ko@samsung.com>
Fri, 25 Nov 2016 05:42:38 +0000 (21:42 -0800)
This patch improves that step to handle situation when manifest
does not exists.

To test:
1. Crash app before StepGenerateXML
2. su app_fw
3. run wgt-backend -b <recovery file> -u 5001
4. Check if you can normally install the same app.

Change-Id: I220157a47e8d7bbeef2710b377e7a70763fac999

src/common/step/filesystem/step_recover_external_storage.cc
src/common/step/filesystem/step_recover_external_storage.h

index f330335..b106ea3 100644 (file)
@@ -4,11 +4,25 @@
 
 #include "common/step/filesystem/step_recover_external_storage.h"
 
+#include <boost/filesystem/operations.hpp>
+#include <boost/filesystem/path.hpp>
+#include <boost/system/error_code.hpp>
+
+namespace bf = boost::filesystem;
+namespace bs = boost::system;
+
 namespace common_installer {
 namespace filesystem {
 
 Step::Status StepRecoverExternalStorage::process() {
-  (void) StepAcquireExternalStorage::process();
+  if (!context_->manifest_data.get()) {
+    bs::error_code error;
+    if (bf::exists(context_->pkg_path.get())) {
+      bf::remove_all(context_->pkg_path.get(), error);
+    }
+  } else {
+    (void) StepAcquireExternalStorage::process();
+  }
   return Status::OK;
 }
 
index 68bac1b..71633e4 100644 (file)
@@ -20,6 +20,8 @@ class StepRecoverExternalStorage : public StepAcquireExternalStorage {
  public:
   using StepAcquireExternalStorage::StepAcquireExternalStorage;
 
+  Status precheck() override { return Status::OK; };
+
   Status process() override;
 
   STEP_NAME(RecoverExternalStorage)