namespace filesystem {
Step::Status StepRecoverFiles::RecoveryNew() {
- if (!RemoveAll(context_->GetPkgPath()))
+ if (!ClearPath(context_->GetPkgPath()))
return Status::RECOVERY_ERROR;
LOG(INFO) << "Package files recovery done";
if (iter->path().filename() == kExternalMemoryMountPoint)
continue;
- if (!RemoveAll(iter->path())) {
+ if (!ClearPath(iter->path())) {
LOG(ERROR) << "Cannot restore widget files to its correct location";
return Status::RECOVERY_ERROR;
}
return Status::RECOVERY_ERROR;
}
- RemoveAll(backup_path);
+ ClearPath(backup_path);
}
LOG(INFO) << "Package files recovery done";
return Status::OK;
bf::path zip_location = GetZipPackageLocation(
context_->GetPkgPath(), context_->pkgid.get());
Remove(zip_location);
- RemoveAll(context_->GetPkgPath());
+ ClearPath(context_->GetPkgPath());
LOG(INFO) << "Package files recovery done";
return Status::OK;
}
bf::path pkg_path =
bf::path(GetRootAppPath(false, context_->uid.get())) /
context_->pkgid.get();
- if (!RemoveAll(pkg_path))
+ if (!ClearPath(pkg_path))
return Status::RECOVERY_ERROR;
LOG(INFO) << "Package files recovery done";
if (!bf::exists(backup_path))
return Status::OK;
- if (!RemoveAll(backup_path)) {
+ if (!ClearPath(backup_path)) {
LOG(ERROR) << "Failed to remove backup path";
return Status::RECOVERY_ERROR;
}
return Status::OK;
}
+bool StepRecoverFiles::ClearPath(const bf::path& path) {
+ return RemoveAll(path);
+}
+
} // namespace filesystem
} // namespace common_installer
#ifndef COMMON_STEP_FILESYSTEM_STEP_RECOVER_FILES_H_
#define COMMON_STEP_FILESYSTEM_STEP_RECOVER_FILES_H_
+#include <boost/filesystem/path.hpp>
+
#include <manifest_parser/utils/logging.h>
#include "common/installer_context.h"
Status RecoveryReadonlyUpdateInstall() override;
Status Cleanup() override;
+ protected:
+ virtual bool ClearPath(const boost::filesystem::path& path);
+
STEP_NAME(RecoverFiles)
};
shared_res_backup_dir_path += ".SharedRes";
if (unpack_dir_path.empty())
return Step::Status::OK;
- if (!RemoveAll(unpack_dir_path) ||
- !RemoveAll(patch_dir_path) ||
- !RemoveAll(mount_dir_path) ||
- !RemoveAll(shared_res_backup_dir_path))
+ if (!ClearPath(unpack_dir_path) ||
+ !ClearPath(patch_dir_path) ||
+ !ClearPath(mount_dir_path) ||
+ !ClearPath(shared_res_backup_dir_path))
return Step::Status::RECOVERY_ERROR;
return Step::Status::OK;
}
+bool StepRemoveTemporaryDirectory::ClearPath(const bf::path& path) {
+ return RemoveAll(path);
+}
+
} // namespace filesystem
} // namespace common_installer
#ifndef COMMON_STEP_FILESYSTEM_STEP_REMOVE_TEMPORARY_DIRECTORY_H_
#define COMMON_STEP_FILESYSTEM_STEP_REMOVE_TEMPORARY_DIRECTORY_H_
+#include <boost/filesystem/path.hpp>
+
#include <manifest_parser/utils/logging.h>
#include "common/step/recovery/step_recovery.h"
Status RecoveryNew() override;
Status RecoveryUpdate() override;
Status Cleanup() override;
+
+ protected:
+ virtual bool ClearPath(const boost::filesystem::path& path);
+
private:
/**
* @brief RemoveFiles