Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Wenbin1002 committed Jan 2, 2025
1 parent 56a798e commit b4bd786
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
3 changes: 0 additions & 3 deletions core/src/services/oss/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -521,11 +521,8 @@ impl Access for OssBackend {
let headers = resp.headers();
let mut meta = self.core.parse_metadata(path, resp.headers())?;

// If version id exists, set the version; otherwise, mark as the current version.
if let Some(v) = parse_header_to_str(headers, "x-oss-version-id")? {
meta.set_version(v);
} else {
meta.set_is_current(true);
}

Ok(RpStat::new(meta))
Expand Down
3 changes: 0 additions & 3 deletions core/src/services/s3/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1016,11 +1016,8 @@ impl Access for S3Backend {
meta.with_user_metadata(user_meta);
}

// If version id exists, set the version; otherwise, mark as the current version.
if let Some(v) = parse_header_to_str(headers, "x-amz-version-id")? {
meta.set_version(v);
} else {
meta.set_is_current(true);
}

Ok(RpStat::new(meta))
Expand Down
30 changes: 19 additions & 11 deletions core/src/types/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,25 +406,33 @@ impl Metadata {
self
}

/// Is_current of this entry.
/// Determines if the provided metadata reflects the current status of the path.
///
/// Is_current is a boolean that can be used to identify
/// if the version of this entry is the latest version.
/// - `Ok(true)` indicates it is the latest status.
/// - `Ok(false)` indicates it is an older version of the file.
/// - `None` indicates uncertainty about its status.
///
/// This API allows users to verify if the version is up-to-date when listing with versions.
pub fn is_current(&self) -> Option<bool> {
self.is_current
}

/// Set is_current of this entry.
///
/// For HeadObject without version_id, we will set it to Some(true).
/// Set the `is_current` status of this entry.
///
/// For HeadObject with version_id, we will set it to None.
///
/// For ListObjects, we will set all keys to Some(true)
/// By default, this value will be `None`. Please avoid using this API if it's unclear whether the entry is current.
/// Set it to `true` if it is known to be the latest; otherwise, set it to `false`.
pub fn with_is_current(mut self, is_current: Option<bool>) -> Self {
self.is_current = is_current;
self
}

/// Set the `is_current` status of this entry.
///
/// For ListObjectVersions, we will decide the value based on IsLatest.
pub fn set_is_current(&mut self, is_current: bool) {
/// By default, this value will be `None`. Please avoid using this API if it's unclear whether the entry is current.
/// Set it to `true` if it is known to be the latest; otherwise, set it to `false`.
pub fn set_is_current(&mut self, is_current: bool) -> &mut Self {
self.is_current = Some(is_current);
self
}

/// User defined metadata of this entry
Expand Down

0 comments on commit b4bd786

Please sign in to comment.