mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-03 20:07:42 +00:00
fix(ecstore): accept illumos non-empty rmdir errors (#4991)
This commit is contained in:
@@ -103,6 +103,10 @@ fn remove_file_if_exists(path: &Path) -> std::io::Result<()> {
|
||||
}
|
||||
}
|
||||
|
||||
fn is_remove_dir_not_empty_error(kind: ErrorKind) -> bool {
|
||||
matches!(kind, ErrorKind::DirectoryNotEmpty | ErrorKind::AlreadyExists)
|
||||
}
|
||||
|
||||
fn remove_dir_all_if_exists(path: &Path) -> std::io::Result<()> {
|
||||
match std::fs::remove_dir_all(path) {
|
||||
Ok(()) => Ok(()),
|
||||
@@ -4361,7 +4365,7 @@ impl LocalDisk {
|
||||
// debug!("remove_dir err {:?} when {:?}", &err, &delete_path);
|
||||
match err.kind() {
|
||||
ErrorKind::NotFound => (),
|
||||
ErrorKind::DirectoryNotEmpty => (),
|
||||
kind if is_remove_dir_not_empty_error(kind) => (),
|
||||
kind => {
|
||||
warn!(
|
||||
event = EVENT_DISK_LOCAL_DELETE_FAILED,
|
||||
@@ -7929,6 +7933,13 @@ mod test {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn remove_dir_not_empty_accepts_illumos_eexist() {
|
||||
assert!(is_remove_dir_not_empty_error(ErrorKind::DirectoryNotEmpty));
|
||||
assert!(is_remove_dir_not_empty_error(ErrorKind::AlreadyExists));
|
||||
assert!(!is_remove_dir_not_empty_error(ErrorKind::PermissionDenied));
|
||||
}
|
||||
|
||||
impl<'a> MakeWriter<'a> for CapturedLogs {
|
||||
type Writer = CapturedLogWriter;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user