Fix StepUpdateTep's undo
[platform/core/appfw/app-installers.git] / src / common / step / filesystem / step_update_tep.cc
index 91ace28..41b5117 100644 (file)
@@ -11,7 +11,7 @@
 #include <cstring>
 #include <string>
 
-#include "common/paths.h"
+#include "common/utils/paths.h"
 #include "common/pkgmgr_registration.h"
 #include "common/utils/file_util.h"
 
@@ -53,7 +53,7 @@ Step::Status StepUpdateTep::process() {
       bf::path new_path = context_->manifest_data.get()->tep_name;
       bf::path backup_path =
           GetInternalTepPath(
-              GetBackupPathForPackagePath(context_->pkg_path.get()));
+              GetBackupPathForPackagePath(context_->GetPkgPath()));
       backup_path /= new_path.filename();
       if (!bf::exists(new_path.parent_path())) {
         bs::error_code error;
@@ -78,18 +78,16 @@ Step::Status StepUpdateTep::clean() {
         strcmp(context_->old_manifest_data.get()->tep_name,
                context_->manifest_data.get()->tep_name)) {
       bf::path old_tep = context_->old_manifest_data.get()->tep_name;
-      bs::error_code error;
-      bf::remove(old_tep, error);
-      if (error) {
-        LOG(WARNING) << "Failed to cleanup old tep package from sd card";
-      }
+      Remove(old_tep);
     }
   }
   return Status::OK;
 }
 
 Step::Status StepUpdateTep::undo() {
-  RemoveAll(context_->tep_path.get());
+  const bf::path& remove_path = context_->tep_path.get();
+  RemoveAll(context_->old_manifest_data.get()->tep_name ?
+      remove_path : remove_path.parent_path());
   return Status::OK;
 }