mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-27 15:37:02 +00:00
delete_bucket todo
This commit is contained in:
@@ -17,6 +17,8 @@
|
|||||||
- [x] 创建 CreateBucket
|
- [x] 创建 CreateBucket
|
||||||
- [x] 列表 ListBuckets
|
- [x] 列表 ListBuckets
|
||||||
- [ ] 桶下面的文件列表 ListObjects
|
- [ ] 桶下面的文件列表 ListObjects
|
||||||
|
- [x] 简单实现功能
|
||||||
|
- [ ] 优化并发读取
|
||||||
- [ ] 删除
|
- [ ] 删除
|
||||||
- [x] 详情 HeadBucket
|
- [x] 详情 HeadBucket
|
||||||
- [ ] 文件操作
|
- [ ] 文件操作
|
||||||
|
|||||||
@@ -877,6 +877,7 @@ impl DiskAPI for LocalDisk {
|
|||||||
async fn delete_volume(&self, volume: &str) -> Result<()> {
|
async fn delete_volume(&self, volume: &str) -> Result<()> {
|
||||||
let p = self.get_bucket_path(volume)?;
|
let p = self.get_bucket_path(volume)?;
|
||||||
|
|
||||||
|
// TODO: 不能用递归删除,如果目录下面有文件,返回errVolumeNotEmpty
|
||||||
fs::remove_dir_all(&p).await?;
|
fs::remove_dir_all(&p).await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -368,6 +368,8 @@ impl PeerS3Client for LocalPeerS3Client {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: errVolumeNotEmpty 不删除,把已经删除的重新创建
|
||||||
|
|
||||||
// TODO: reduceWriteQuorumErrs
|
// TODO: reduceWriteQuorumErrs
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
+42
-2
@@ -1,6 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
bucket_meta::BucketMetadata,
|
bucket_meta::BucketMetadata,
|
||||||
disk::{error::DiskError, DiskOption, DiskStore, WalkDirOptions, RUSTFS_META_BUCKET},
|
disk::{error::DiskError, DeleteOptions, DiskOption, DiskStore, WalkDirOptions, BUCKET_META_PREFIX, RUSTFS_META_BUCKET},
|
||||||
disks_layout::DisksLayout,
|
disks_layout::DisksLayout,
|
||||||
endpoints::EndpointServerPools,
|
endpoints::EndpointServerPools,
|
||||||
error::{Error, Result},
|
error::{Error, Result},
|
||||||
@@ -16,7 +16,7 @@ use futures::future::join_all;
|
|||||||
use http::HeaderMap;
|
use http::HeaderMap;
|
||||||
use s3s::{dto::StreamingBlob, Body};
|
use s3s::{dto::StreamingBlob, Body};
|
||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::{HashMap, HashSet};
|
||||||
use tracing::warn;
|
use tracing::{debug, warn};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@@ -190,6 +190,43 @@ impl ECStore {
|
|||||||
|
|
||||||
Ok(ress)
|
Ok(ress)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn delete_all(&self, bucket: &str, prefix: &str) -> Result<()> {
|
||||||
|
let mut futures = Vec::new();
|
||||||
|
for sets in self.pools.iter() {
|
||||||
|
for set in sets.disk_set.iter() {
|
||||||
|
for disk in set.disks.iter() {
|
||||||
|
if disk.is_none() {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
let disk = disk.as_ref().unwrap();
|
||||||
|
futures.push(disk.delete(
|
||||||
|
bucket,
|
||||||
|
prefix,
|
||||||
|
DeleteOptions {
|
||||||
|
recursive: true,
|
||||||
|
immediate: false,
|
||||||
|
},
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let results = join_all(futures).await;
|
||||||
|
|
||||||
|
let mut errs = Vec::new();
|
||||||
|
|
||||||
|
for res in results {
|
||||||
|
match res {
|
||||||
|
Ok(_) => errs.push(None),
|
||||||
|
Err(e) => errs.push(Some(e)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
debug!("store delete_all errs {:?}", errs);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
@@ -381,6 +418,9 @@ impl StorageAPI for ECStore {
|
|||||||
async fn delete_bucket(&self, bucket: &str) -> Result<()> {
|
async fn delete_bucket(&self, bucket: &str) -> Result<()> {
|
||||||
self.peer_sys.delete_bucket(bucket).await?;
|
self.peer_sys.delete_bucket(bucket).await?;
|
||||||
|
|
||||||
|
// 删除meta
|
||||||
|
self.delete_all(RUSTFS_META_BUCKET, format!("{}/{}", BUCKET_META_PREFIX, bucket).as_str())
|
||||||
|
.await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ use s3s::S3;
|
|||||||
use s3s::{S3Request, S3Response};
|
use s3s::{S3Request, S3Response};
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use tracing::warn;
|
|
||||||
use transform_stream::AsyncTryStream;
|
use transform_stream::AsyncTryStream;
|
||||||
|
|
||||||
use ecstore::error::Result;
|
use ecstore::error::Result;
|
||||||
|
|||||||
Reference in New Issue
Block a user