Skip to content

Commit

Permalink
add stat_with_versioning, read_with_versioning, delete_with_versionin…
Browse files Browse the repository at this point in the history
…g, list_with_versioning_capabilities
  • Loading branch information
meteorgan committed Sep 24, 2024
1 parent 96d878c commit 413a432
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 20 deletions.
8 changes: 5 additions & 3 deletions core/src/services/s3/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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()
});

Expand Down
17 changes: 11 additions & 6 deletions core/src/types/capability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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 {
Expand Down
5 changes: 2 additions & 3 deletions core/tests/behavior/async_delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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(());
}

Expand Down
6 changes: 3 additions & 3 deletions core/tests/behavior/async_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(());
}

Expand Down Expand Up @@ -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(());
}

Expand Down Expand Up @@ -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(());
}

Expand Down
4 changes: 2 additions & 2 deletions core/tests/behavior/async_read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(());
}

Expand Down Expand Up @@ -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(());
}

Expand Down
5 changes: 2 additions & 3 deletions core/tests/behavior/async_stat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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(());
}

Expand Down

0 comments on commit 413a432

Please sign in to comment.