Fix StepAcquireExternalStorage 96/83296/2
authorSangyoon Jang <s89.jang@samsung.com>
Wed, 10 Aug 2016 04:55:15 +0000 (13:55 +0900)
committerjongmyeong ko <jongmyeong.ko@samsung.com>
Wed, 10 Aug 2016 05:46:05 +0000 (22:46 -0700)
Get installed storage from pkgmgr db when processing installed package.

Change-Id: I444eecd0caa1fe6b71b1dbbf58a542192e403172
Signed-off-by: Sangyoon Jang <s89.jang@samsung.com>
src/common/step/filesystem/step_acquire_external_storage.cc
src/common/step/filesystem/step_acquire_external_storage.h

index 1b3a4b5..99ef814 100644 (file)
@@ -10,6 +10,7 @@
 #include <cstring>
 
 #include "common/external_storage.h"
+#include "common/pkgmgr_query.h"
 
 namespace {
 
@@ -29,6 +30,12 @@ enum class Storage {
 namespace common_installer {
 namespace filesystem {
 
+StepAcquireExternalStorage::StepAcquireExternalStorage(
+    InstallerContext* context, bool installed)
+    : Step(context),
+      installed_(installed) {
+}
+
 Step::Status StepAcquireExternalStorage::precheck() {
   if (!context_->manifest_data.get()) {
     LOG(ERROR) << "Manifest data is empty";
@@ -39,15 +46,16 @@ Step::Status StepAcquireExternalStorage::precheck() {
 
 Step::Status StepAcquireExternalStorage::process() {
   manifest_x* manifest = context_->manifest_data.get();
-  manifest_x* old_manifest = context_->old_manifest_data.get();
 
   Storage storage = Storage::NONE;
   // in case of update
-  if (old_manifest) {
-    storage = Storage::INTERNAL;
-    if (old_manifest->installed_storage)
-      if (!strcmp(old_manifest->installed_storage, kInstalledExternally))
-        storage = Storage::EXTERNAL;
+  if (installed_) {
+    std::string storage_str = QueryStorageForPkgId(context_->pkgid.get(),
+        context_->uid.get());
+    if (!strcmp(storage_str.c_str(), kInstalledExternally))
+      storage = Storage::EXTERNAL;
+    else
+      storage = Storage::INTERNAL;
   } else {
     if (!strcmp(manifest->installlocation, kInternalOnly)) {
       storage = Storage::INTERNAL;
index 5f583a5..58c3941 100644 (file)
@@ -20,12 +20,17 @@ class StepAcquireExternalStorage : public Step {
  public:
   using Step::Step;
 
+  explicit StepAcquireExternalStorage(InstallerContext* context,
+      bool installed);
+
   Status process() override;
 
   Status clean() override { return Status::OK; }
   Status undo() override { return Status::OK; }
   Status precheck() override;
 
+  bool installed_;
+
   STEP_NAME(AcquireExternalStorage)
 };