From 413a432219cfacfed9d1e0c9380db898e1aaa623 Mon Sep 17 00:00:00 2001 From: meteorgan Date: Tue, 24 Sep 2024 16:41:28 +0800 Subject: [PATCH] add stat_with_versioning, read_with_versioning, delete_with_versioning, list_with_versioning_capabilities --- core/src/services/s3/backend.rs | 8 +++++--- core/src/types/capability.rs | 17 +++++++++++------ core/tests/behavior/async_delete.rs | 5 ++--- core/tests/behavior/async_list.rs | 6 +++--- core/tests/behavior/async_read.rs | 4 ++-- core/tests/behavior/async_stat.rs | 5 ++--- 6 files changed, 25 insertions(+), 20 deletions(-) diff --git a/core/src/services/s3/backend.rs b/core/src/services/s3/backend.rs index 9b6c8f95898..a054770bd68 100644 --- a/core/src/services/s3/backend.rs +++ b/core/src/services/s3/backend.rs @@ -902,14 +902,15 @@ impl Access for S3Backend { stat_with_override_cache_control: !self.core.disable_stat_with_override, stat_with_override_content_disposition: !self.core.disable_stat_with_override, stat_with_override_content_type: !self.core.disable_stat_with_override, + stat_with_versioning: self.core.enable_versioning, read: true, - read_with_if_match: true, read_with_if_none_match: true, read_with_override_cache_control: true, read_with_override_content_disposition: true, read_with_override_content_type: true, + read_with_versioning: self.core.enable_versioning, write: true, write_can_empty: true, @@ -932,12 +933,15 @@ impl Access for S3Backend { }, delete: true, + delete_with_versioning: self.core.enable_versioning, + copy: true, list: true, list_with_limit: true, list_with_start_after: true, list_with_recursive: true, + list_with_versioning: self.core.enable_versioning, presign: true, presign_stat: true, @@ -947,8 +951,6 @@ impl Access for S3Backend { batch: true, batch_max_operations: Some(self.core.batch_max_operations), - versioning: self.core.enable_versioning, - ..Default::default() }); diff --git a/core/src/types/capability.rs b/core/src/types/capability.rs index b3b654feaeb..78ecb00205f 100644 --- a/core/src/types/capability.rs +++ b/core/src/types/capability.rs @@ -61,12 +61,14 @@ pub struct Capability { pub stat_with_if_match: bool, /// If operator supports stat with if none match. pub stat_with_if_none_match: bool, - /// if operator supports read with override cache control. + /// if operator supports stat with override cache control. pub stat_with_override_cache_control: bool, - /// if operator supports read with override content disposition. + /// if operator supports stat with override content disposition. pub stat_with_override_content_disposition: bool, - /// if operator supports read with override content type. + /// if operator supports stat with override content type. pub stat_with_override_content_type: bool, + /// if operator supports stat with versioning. + pub stat_with_versioning: bool, /// If operator supports read. pub read: bool, @@ -80,6 +82,8 @@ pub struct Capability { pub read_with_override_content_disposition: bool, /// if operator supports read with override content type. pub read_with_override_content_type: bool, + /// if operator supports read with versioning. + pub read_with_versioning: bool, /// If operator supports write. pub write: bool, @@ -119,6 +123,8 @@ pub struct Capability { /// If operator supports delete. pub delete: bool, + /// if operator supports delete with versioning. + pub delete_with_versioning: bool, /// If operator supports copy. pub copy: bool, @@ -134,6 +140,8 @@ pub struct Capability { pub list_with_start_after: bool, /// If backend supports list with recursive. pub list_with_recursive: bool, + /// if operator supports list with versioning. + pub list_with_versioning: bool, /// If operator supports presign. pub presign: bool, @@ -153,9 +161,6 @@ pub struct Capability { /// If operator supports blocking. pub blocking: bool, - - /// If operator supports versioning - pub versioning: bool, } impl Debug for Capability { diff --git a/core/tests/behavior/async_delete.rs b/core/tests/behavior/async_delete.rs index f8b2426791c..44ef3afc8ce 100644 --- a/core/tests/behavior/async_delete.rs +++ b/core/tests/behavior/async_delete.rs @@ -216,13 +216,12 @@ pub async fn test_remove_all_with_prefix_exists(op: Operator) -> Result<()> { } pub async fn test_delete_with_version(op: Operator) -> Result<()> { - if !op.info().full_capability().versioning { + if !op.info().full_capability().delete_with_versioning { return Ok(()); } let (path, content, _) = TEST_FIXTURE.new_file(op.clone()); - //TODO: refactor these code after `write` operation can return metadata op.write(path.as_str(), content) .await .expect("write must success"); @@ -253,7 +252,7 @@ pub async fn test_delete_with_version(op: Operator) -> Result<()> { } pub async fn test_delete_with_not_existing_version(op: Operator) -> Result<()> { - if !op.info().full_capability().versioning { + if !op.info().full_capability().delete_with_versioning { return Ok(()); } diff --git a/core/tests/behavior/async_list.rs b/core/tests/behavior/async_list.rs index f48c689ab7c..86d2aa33caf 100644 --- a/core/tests/behavior/async_list.rs +++ b/core/tests/behavior/async_list.rs @@ -684,7 +684,7 @@ pub async fn test_list_only(op: Operator) -> Result<()> { } pub async fn test_list_files_with_version(op: Operator) -> Result<()> { - if !op.info().full_capability().versioning { + if !op.info().full_capability().list_with_versioning { return Ok(()); } @@ -722,7 +722,7 @@ pub async fn test_list_with_version_and_limit(op: Operator) -> Result<()> { if op.info().scheme() == Scheme::Gdrive { return Ok(()); } - if !op.info().full_capability().versioning { + if !op.info().full_capability().list_with_versioning { return Ok(()); } @@ -775,7 +775,7 @@ pub async fn test_list_with_version_and_limit(op: Operator) -> Result<()> { } pub async fn test_list_with_version_and_start_after(op: Operator) -> Result<()> { - if !op.info().full_capability().versioning { + if !op.info().full_capability().list_with_versioning { return Ok(()); } diff --git a/core/tests/behavior/async_read.rs b/core/tests/behavior/async_read.rs index e3fbbb26060..19e48aad3f7 100644 --- a/core/tests/behavior/async_read.rs +++ b/core/tests/behavior/async_read.rs @@ -557,7 +557,7 @@ pub async fn test_read_only_read_with_if_none_match(op: Operator) -> anyhow::Res } pub async fn test_read_with_version(op: Operator) -> anyhow::Result<()> { - if !op.info().full_capability().versioning { + if !op.info().full_capability().read_with_versioning { return Ok(()); } @@ -591,7 +591,7 @@ pub async fn test_read_with_version(op: Operator) -> anyhow::Result<()> { } pub async fn test_read_with_not_existing_version(op: Operator) -> anyhow::Result<()> { - if !op.info().full_capability().versioning { + if !op.info().full_capability().read_with_versioning { return Ok(()); } diff --git a/core/tests/behavior/async_stat.rs b/core/tests/behavior/async_stat.rs index 0c3aa63d67b..967985995d2 100644 --- a/core/tests/behavior/async_stat.rs +++ b/core/tests/behavior/async_stat.rs @@ -502,13 +502,12 @@ pub async fn test_read_only_stat_root(op: Operator) -> Result<()> { } pub async fn test_stat_with_version(op: Operator) -> Result<()> { - if !op.info().full_capability().versioning { + if !op.info().full_capability().stat_with_versioning { return Ok(()); } let (path, content, _) = TEST_FIXTURE.new_file(op.clone()); - //TODO: refactor these code after `write` operation can return metadata op.write(path.as_str(), content.clone()) .await .expect("write must success"); @@ -541,7 +540,7 @@ pub async fn test_stat_with_version(op: Operator) -> Result<()> { } pub async fn stat_with_not_existing_version(op: Operator) -> Result<()> { - if !op.info().full_capability().versioning { + if !op.info().full_capability().stat_with_versioning { return Ok(()); }