Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
geetanshjuneja committed Dec 30, 2024
1 parent 6be969c commit 08deaf4
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 25 deletions.
6 changes: 3 additions & 3 deletions core/src/layers/capability_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ impl<A: Access> LayeredAccess for CapabilityAccessor<A> {

async fn list(&self, path: &str, args: OpList) -> crate::Result<(RpList, Self::Lister)> {
let capability = self.info.full_capability();
if !capability.list_with_version && args.versioned() {
if !capability.list_with_versioned && args.versioned() {
return Err(new_unsupported_error(
self.info.as_ref(),
Operation::List,
Expand Down Expand Up @@ -191,7 +191,7 @@ impl<A: Access> LayeredAccess for CapabilityAccessor<A> {
args: OpList,
) -> crate::Result<(RpList, Self::BlockingLister)> {
let capability = self.info.full_capability();
if !capability.list_with_version && args.versioned() {
if !capability.list_with_versioned && args.versioned() {
return Err(new_unsupported_error(
self.info.as_ref(),
Operation::BlockingList,
Expand Down Expand Up @@ -295,7 +295,7 @@ mod tests {

let op = new_test_operator(Capability {
list: true,
list_with_version: true,
list_with_versioned: true,
..Default::default()
});
let res = op.lister_with("path/").version(true).await;
Expand Down
19 changes: 13 additions & 6 deletions core/src/raw/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ pub struct OpList {
/// by the underlying service
///
/// Default to `false`
version: bool,
versioned: bool,
}

impl Default for OpList {
Expand All @@ -121,7 +121,7 @@ impl Default for OpList {
start_after: None,
recursive: false,
concurrent: 1,
version: false,
versioned: false,
}
}
}
Expand Down Expand Up @@ -184,20 +184,27 @@ impl OpList {
}

/// Change the version of this list operation
#[deprecated(since = "0.51.1", note = "use versioned instead")]
pub fn with_version(mut self, version: bool) -> Self {
self.version = version;
self.versioned = version;
self
}

/// Change the version of this list operation
pub fn with_versioned(mut self, versioned: bool) -> Self {
self.versioned = versioned;
self
}

/// Get the version of this list operation
#[deprecated = "use versioned instead"]
#[deprecated(since = "0.51.1", note = "use versioned instead")]
pub fn version(&self) -> bool {
self.version
self.versioned
}

/// Get the version of this list operation
pub fn versioned(&self) -> bool {
self.version
self.versioned
}
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/services/s3/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,7 @@ impl Access for S3Backend {
list_with_limit: true,
list_with_start_after: true,
list_with_recursive: true,
list_with_version: self.core.enable_versioning,
list_with_versioned: self.core.enable_versioning,
list_has_etag: true,
list_has_content_md5: true,
list_has_content_length: true,
Expand Down
4 changes: 2 additions & 2 deletions core/src/types/capability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ pub struct Capability {
/// Indicates if recursive listing is supported.
pub list_with_recursive: bool,
/// Indicates if versioned listing is supported.
pub list_with_version: bool,
pub list_with_versioned: bool,
/// Indicates whether cache control information is available in list response
pub list_has_cache_control: bool,
/// Indicates whether content disposition information is available in list response
Expand All @@ -193,7 +193,7 @@ pub struct Capability {
/// Indicates whether last modified timestamp is available in list response
pub list_has_last_modified: bool,
/// Indicates whether version information is available in list response
pub list_has_version: bool,
pub list_has_versioned: bool,
/// Indicates whether user-defined metadata is available in list response
pub list_has_user_metadata: bool,

Expand Down
8 changes: 4 additions & 4 deletions core/src/types/operator/operator_futures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -486,9 +486,9 @@ impl<F: Future<Output = Result<Vec<Entry>>>> FutureList<F> {
/// by the underlying service
///
/// Default to `false`
#[deprecated = "use versioned instead"]
#[deprecated(since = "0.51.1", note = "use versioned instead")]
pub fn version(self, v: bool) -> Self {
self.map(|args| args.with_version(v))
self.map(|args| args.with_versioned(v))
}

/// The version is used to control whether the object versions should be returned.
Expand All @@ -499,7 +499,7 @@ impl<F: Future<Output = Result<Vec<Entry>>>> FutureList<F> {
///
/// Default to `false`
pub fn versioned(self, v: bool) -> Self {
self.map(|args| args.with_version(v))
self.map(|args| args.with_versioned(v))
}
}

Expand Down Expand Up @@ -541,6 +541,6 @@ impl<F: Future<Output = Result<Lister>>> FutureLister<F> {
///
/// Default to `false`
pub fn version(self, v: bool) -> Self {
self.map(|args| args.with_version(v))
self.map(|args| args.with_versioned(v))
}
}
18 changes: 9 additions & 9 deletions core/tests/behavior/async_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ pub fn tests(op: &Operator, tests: &mut Vec<Trial>) {
test_list_file_with_recursive,
test_list_root_with_recursive,
test_remove_all,
test_list_files_with_version,
test_list_with_version_and_limit,
test_list_with_version_and_start_after
test_list_files_with_versioned,
test_list_with_versioned_and_limit,
test_list_with_versioned_and_start_after
))
}

Expand Down Expand Up @@ -575,8 +575,8 @@ pub async fn test_list_only(op: Operator) -> Result<()> {
Ok(())
}

pub async fn test_list_files_with_version(op: Operator) -> Result<()> {
if !op.info().full_capability().list_with_version {
pub async fn test_list_files_with_versioned(op: Operator) -> Result<()> {
if !op.info().full_capability().list_with_versioned {
return Ok(());
}

Expand Down Expand Up @@ -608,13 +608,13 @@ pub async fn test_list_files_with_version(op: Operator) -> Result<()> {
}

// listing a directory with version, which contains more object versions than a page can take
pub async fn test_list_with_version_and_limit(op: Operator) -> Result<()> {
pub async fn test_list_with_versioned_and_limit(op: Operator) -> Result<()> {
// Gdrive think that this test is an abuse of their service and redirect us
// to an infinite loop. Let's ignore this test for gdrive.
if op.info().scheme() == Scheme::Gdrive {
return Ok(());
}
if !op.info().full_capability().list_with_version {
if !op.info().full_capability().list_with_versioned {
return Ok(());
}

Expand Down Expand Up @@ -648,8 +648,8 @@ pub async fn test_list_with_version_and_limit(op: Operator) -> Result<()> {
Ok(())
}

pub async fn test_list_with_version_and_start_after(op: Operator) -> Result<()> {
if !op.info().full_capability().list_with_version {
pub async fn test_list_with_versioned_and_start_after(op: Operator) -> Result<()> {
if !op.info().full_capability().list_with_versioned {
return Ok(());
}

Expand Down

0 comments on commit 08deaf4

Please sign in to comment.