mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-30 16:59:52 +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<()> {
|
fn remove_dir_all_if_exists(path: &Path) -> std::io::Result<()> {
|
||||||
match std::fs::remove_dir_all(path) {
|
match std::fs::remove_dir_all(path) {
|
||||||
Ok(()) => Ok(()),
|
Ok(()) => Ok(()),
|
||||||
@@ -4361,7 +4365,7 @@ impl LocalDisk {
|
|||||||
// debug!("remove_dir err {:?} when {:?}", &err, &delete_path);
|
// debug!("remove_dir err {:?} when {:?}", &err, &delete_path);
|
||||||
match err.kind() {
|
match err.kind() {
|
||||||
ErrorKind::NotFound => (),
|
ErrorKind::NotFound => (),
|
||||||
ErrorKind::DirectoryNotEmpty => (),
|
kind if is_remove_dir_not_empty_error(kind) => (),
|
||||||
kind => {
|
kind => {
|
||||||
warn!(
|
warn!(
|
||||||
event = EVENT_DISK_LOCAL_DELETE_FAILED,
|
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 {
|
impl<'a> MakeWriter<'a> for CapturedLogs {
|
||||||
type Writer = CapturedLogWriter;
|
type Writer = CapturedLogWriter;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user