mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-06 05:17:42 +00:00
add delete_bucket opts
This commit is contained in:
@@ -31,6 +31,9 @@ pub enum DiskError {
|
||||
|
||||
#[error("volume not found")]
|
||||
VolumeNotFound,
|
||||
|
||||
#[error("volume not empty")]
|
||||
VolumeNotEmpty,
|
||||
}
|
||||
|
||||
impl DiskError {
|
||||
|
||||
@@ -972,7 +972,20 @@ impl DiskAPI for LocalDisk {
|
||||
let p = self.get_bucket_path(volume)?;
|
||||
|
||||
// TODO: 不能用递归删除,如果目录下面有文件,返回errVolumeNotEmpty
|
||||
fs::remove_dir_all(&p).await?;
|
||||
|
||||
if let Err(err) = fs::remove_dir_all(&p).await {
|
||||
match err.kind() {
|
||||
ErrorKind::NotFound => (),
|
||||
// ErrorKind::DirectoryNotEmpty => (),
|
||||
kind => {
|
||||
if kind.to_string() == "directory not empty" {
|
||||
return Err(Error::new(DiskError::VolumeNotEmpty));
|
||||
}
|
||||
|
||||
return Err(Error::from(err));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user