From 6165ac334bc6038892d08f1d57764c9f97723757 Mon Sep 17 00:00:00 2001 From: weisd Date: Mon, 29 Jul 2024 15:08:27 +0800 Subject: [PATCH] test:abort_multipart_upload --- TODO.md | 30 +++++++++++++++--------------- ecstore/src/sets.rs | 6 +++++- ecstore/src/store.rs | 7 +++++++ ecstore/src/store_api.rs | 1 + rustfs/src/storage/ecfs.rs | 12 +++++++++++- 5 files changed, 39 insertions(+), 17 deletions(-) diff --git a/TODO.md b/TODO.md index c300e1d7..eff31bb6 100644 --- a/TODO.md +++ b/TODO.md @@ -2,22 +2,22 @@ ## 基础存储 - - [ ] 上传同名文件时,删除旧版本文件 - - [ ] EC可用读写数量判断 - - [ ] 小文件存储到metafile, inlinedata - - [ ] 错误类型判断,程序中判断错误类型,如何统一错误 - - [ ] 优化并发执行 - - [ ] 抽象出metafile存储 - - [ ] 代码优化 +- [ ] 上传同名文件时,删除旧版本文件 +- [ ] EC可用读写数量判断 +- [ ] 小文件存储到metafile, inlinedata +- [ ] 错误类型判断,程序中判断错误类型,如何统一错误 +- [ ] 优化并发执行 +- [ ] 抽象出metafile存储 +- [ ] 代码优化 ## 基础功能 - - [ ] 桶操作 - - [x] 创建 CreateBucket - - [x] 列表 ListBuckets - - [ ] 桶下面的文件列表 ListObjects - - [x] 详情 HeadBucket - - [ ] 删除 +- [ ] 桶操作 + - [x] 创建 CreateBucket + - [x] 列表 ListBuckets + - [ ] 桶下面的文件列表 ListObjects +- [x] 详情 HeadBucket +- [ ] 删除 - [ ] 文件操作 - [x] 上传 PutObject - [ ] 大文件上传 @@ -28,10 +28,10 @@ - [x] 下载 GetObject - [ ] 复制 CopyObject - [ ] 详情 HeadObject - - [ ] 删除 + - [ ] 删除 ## 扩展功能 - [ ] 版本控制 - [ ] 对象锁 -- [ ] 修复 \ No newline at end of file +- [ ] 修复 diff --git a/ecstore/src/sets.rs b/ecstore/src/sets.rs index baea12ae..79a69950 100644 --- a/ecstore/src/sets.rs +++ b/ecstore/src/sets.rs @@ -169,7 +169,11 @@ impl StorageAPI for Sets { async fn new_multipart_upload(&self, bucket: &str, object: &str, opts: &ObjectOptions) -> Result { self.get_disks_by_key(object).new_multipart_upload(bucket, object, opts).await } - + async fn abort_multipart_upload(&self, bucket: &str, object: &str, upload_id: &str, opts: &ObjectOptions) -> Result<()> { + self.get_disks_by_key(object) + .abort_multipart_upload(bucket, object, upload_id, opts) + .await + } async fn complete_multipart_upload( &self, bucket: &str, diff --git a/ecstore/src/store.rs b/ecstore/src/store.rs index 51955ad7..62776705 100644 --- a/ecstore/src/store.rs +++ b/ecstore/src/store.rs @@ -217,6 +217,13 @@ impl StorageAPI for ECStore { } unimplemented!() } + async fn abort_multipart_upload(&self, bucket: &str, object: &str, upload_id: &str, opts: &ObjectOptions) -> Result<()> { + if self.single_pool() { + return self.pools[0].abort_multipart_upload(bucket, object, upload_id, opts).await; + } + + unimplemented!() + } async fn complete_multipart_upload( &self, bucket: &str, diff --git a/ecstore/src/store_api.rs b/ecstore/src/store_api.rs index 0e8ec934..89cb283c 100644 --- a/ecstore/src/store_api.rs +++ b/ecstore/src/store_api.rs @@ -448,6 +448,7 @@ pub trait StorageAPI { opts: &ObjectOptions, ) -> Result; async fn new_multipart_upload(&self, bucket: &str, object: &str, opts: &ObjectOptions) -> Result; + async fn abort_multipart_upload(&self, bucket: &str, object: &str, upload_id: &str, opts: &ObjectOptions) -> Result<()>; async fn complete_multipart_upload( &self, bucket: &str, diff --git a/rustfs/src/storage/ecfs.rs b/rustfs/src/storage/ecfs.rs index 6712973f..48a46f10 100644 --- a/rustfs/src/storage/ecfs.rs +++ b/rustfs/src/storage/ecfs.rs @@ -433,8 +433,18 @@ impl S3 for FS { #[tracing::instrument(level = "debug", skip(self))] async fn abort_multipart_upload( &self, - _req: S3Request, + req: S3Request, ) -> S3Result> { + let AbortMultipartUploadInput { + bucket, key, upload_id, .. + } = req.input; + + let opts = &ObjectOptions::default(); + try_!( + self.store + .abort_multipart_upload(bucket.as_str(), key.as_str(), upload_id.as_str(), opts) + .await + ); Ok(S3Response::new(AbortMultipartUploadOutput { ..Default::default() })) } }