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;
}
// still unpacked due to necessity.
bf::path backup_path = GetBackupPathForPackagePath(context_->GetPkgPath());
if (bf::exists(backup_path)) {
- if (!MoveDir(backup_path, context_->GetPkgPath(),
- FS_MERGE_OVERWRITE | FS_COMMIT_COPY_FILE)) {
- LOG(ERROR) << "Failed to recovery backup file "
- << "in recovery of mount update";
- return Status::APP_DIR_ERROR;
+ for (bf::directory_iterator iter(backup_path);
+ iter != bf::directory_iterator(); ++iter) {
+ ClearPath(context_->GetPkgPath() / iter->path().filename());
+ if (!Move(iter->path(), context_->GetPkgPath())) {
+ LOG(ERROR) << "Failed to recovery backup file(" << iter->path()
+ << ") in recovery of mount update";
+ return Status::RECOVERY_ERROR;
+ }
}
+ ClearPath(backup_path);
}
LOG(INFO) << "Package files recovery done";
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