Skip to content

Commit b4bd786

Browse files
committed
fix
1 parent 56a798e commit b4bd786

3 files changed

Lines changed: 19 additions & 17 deletions

File tree

core/src/services/oss/backend.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -521,11 +521,8 @@ impl Access for OssBackend {
521521
let headers = resp.headers();
522522
let mut meta = self.core.parse_metadata(path, resp.headers())?;
523523

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

531528
Ok(RpStat::new(meta))

core/src/services/s3/backend.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,11 +1016,8 @@ impl Access for S3Backend {
10161016
meta.with_user_metadata(user_meta);
10171017
}
10181018

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

10261023
Ok(RpStat::new(meta))

core/src/types/metadata.rs

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -406,25 +406,33 @@ impl Metadata {
406406
self
407407
}
408408

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

417-
/// Set is_current of this entry.
418-
///
419-
/// For HeadObject without version_id, we will set it to Some(true).
420+
/// Set the `is_current` status of this entry.
420421
///
421-
/// For HeadObject with version_id, we will set it to None.
422-
///
423-
/// For ListObjects, we will set all keys to Some(true)
422+
/// By default, this value will be `None`. Please avoid using this API if it's unclear whether the entry is current.
423+
/// Set it to `true` if it is known to be the latest; otherwise, set it to `false`.
424+
pub fn with_is_current(mut self, is_current: Option<bool>) -> Self {
425+
self.is_current = is_current;
426+
self
427+
}
428+
429+
/// Set the `is_current` status of this entry.
424430
///
425-
/// For ListObjectVersions, we will decide the value based on IsLatest.
426-
pub fn set_is_current(&mut self, is_current: bool) {
431+
/// By default, this value will be `None`. Please avoid using this API if it's unclear whether the entry is current.
432+
/// Set it to `true` if it is known to be the latest; otherwise, set it to `false`.
433+
pub fn set_is_current(&mut self, is_current: bool) -> &mut Self {
427434
self.is_current = Some(is_current);
435+
self
428436
}
429437

430438
/// User defined metadata of this entry

0 commit comments

Comments
 (0)