Apply IZipInterface and MountBase into StepUnmount 98/239698/5
authorJunghyun Yeon <jungh.yeon@samsung.com>
Wed, 29 Jul 2020 05:14:02 +0000 (14:14 +0900)
committerJunghyun Yeon <jungh.yeon@samsung.com>
Wed, 5 Aug 2020 10:13:41 +0000 (10:13 +0000)
Change-Id: I26c4bb3c3db275ee7d376f53ab4b4a7fa3a08b7e
Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
src/common/step/mount/step_unmount.cc
src/common/step/mount/step_unmount.h

index ad547ca..7fad89d 100644 (file)
@@ -11,6 +11,7 @@
 
 #include "common/utils/paths.h"
 #include "common/tzip_interface.h"
+#include "common/zip_interface.h"
 
 namespace bf = boost::filesystem;
 namespace bs = boost::system;
@@ -19,9 +20,10 @@ namespace common_installer {
 namespace mount {
 
 Step::Status StepUnmount::process() {
-  bf::path mount_point = GetMountLocation(context_->GetPkgPath());
-  TzipInterface tzip_final(mount_point);
-  if (!tzip_final.UnmountZip()) {
+  auto zip_final = CreateZipInterface(
+      GetMountLocation(context_->GetPkgPath()));
+
+  if (!zip_final->UnmountZip()) {
     LOG(ERROR) << "Failed to unmount zip package after installation";
     return Status::APP_DIR_ERROR;
   }
@@ -29,5 +31,12 @@ Step::Status StepUnmount::process() {
   return Status::OK;
 }
 
+std::unique_ptr<IZipInterface> StepUnmount::CreateZipInterface(
+    const boost::filesystem::path& mount_path) {
+  std::unique_ptr<IZipInterface> zip_interface(
+      new TzipInterface(mount_path));
+  return zip_interface;
+}
+
 }  // namespace mount
 }  // namespace common_installer
index bec722e..9df55ea 100644 (file)
@@ -8,6 +8,7 @@
 #include <manifest_parser/utils/logging.h>
 
 #include "common/installer_context.h"
+#include "common/mount_base.h"
 #include "common/step/step.h"
 
 namespace common_installer {
@@ -17,16 +18,21 @@ namespace mount {
  * \brief Responsible for checking existance of mount path to perform
  *
  */
-class StepUnmount : public Step {
+class StepUnmount : public MountBase, public Step {
  public:
   using Step::Step;
+  using MountBase::MountBase;
 
   Status process() override;
   Status clean() override { return Status::OK; }
   Status undo() override { return Status::OK; }
   Status precheck() override { return Status::OK; }
 
-  STEP_NAME(Unmount)
+ protected:
+  std::unique_ptr<IZipInterface> CreateZipInterface(
+      const boost::filesystem::path& mount_path) override;
+
+  STEP_NAME(Unmount);
 };
 
 }  // namespace mount