fix build check and make rename robust in DiskS3::restoreFileOperations

This commit is contained in:
LiuYangkuan 2021-11-12 19:42:25 +08:00
parent f7078a17ce
commit 4366fcbc83
2 changed files with 7 additions and 3 deletions

View File

@ -106,11 +106,11 @@ private:
};
class DiskLocalDirectoryIterator : public IDiskDirectoryIterator
class DiskLocalDirectoryIterator final : public IDiskDirectoryIterator
{
public:
DiskLocalDirectoryIterator() {}
explicit DiskLocalDirectoryIterator(const String & disk_path_, const String & dir_path_)
DiskLocalDirectoryIterator() { }
DiskLocalDirectoryIterator(const String & disk_path_, const String & dir_path_)
: dir_path(dir_path_), entry(fs::path(disk_path_) / dir_path_)
{
}

View File

@ -1002,6 +1002,10 @@ void DiskS3::restoreFileOperations(const RestoreInformation & restore_informatio
else
to_path /= from_path.filename();
/// to_path may exist and non-empty in case for example abrupt restart, so remove it before rename
if (metadata_disk->exists(to_path))
metadata_disk->removeRecursive(to_path);
metadata_disk->moveDirectory(from_path, to_path);
}
}