bool StepCopyBackup::RollbackApplicationDirectory() {
bs::error_code error;
- if (bf::exists(context_->GetPkgPath())) {
- bf::remove_all(context_->GetPkgPath(), error);
- if (error) {
- return false;
+ bf::path root_path = context_->GetPkgPath();
+ if (bf::exists(root_path)) {
+ for (bf::directory_iterator iter(root_path);
+ iter != bf::directory_iterator(); ++iter) {
+ bf::remove_all(iter->path(), error);
+ if (error)
+ return false;
}
}
- if (!MoveDir(backup_path_, context_->GetPkgPath())) {
- return false;
+ for (bf::directory_iterator iter(backup_path_);
+ iter != bf::directory_iterator(); ++iter) {
+ if (!Move(iter->path(), root_path)) {
+ LOG(ERROR) << "Failed to recovery backup file(" << iter->path() << ")";
+ return false;
+ }
}
+ RemoveAll(backup_path_);
uid_t uid = context_->uid.get();
// restore ownership changed during installation