refactor: improve object listing and version handling

- Refactor find_version_index to accept Uuid directly instead of string
- Split from_meta_cache_entries_sorted into separate methods for versions and infos
- Add support for after_version_id filtering in version listing
- Fix S3 error code for replication configuration not found
- Improve error handling and logging levels
- Clean up import statements and remove debug code
This commit is contained in:
weisd
2025-06-24 11:10:23 +08:00
parent 364c3098b2
commit 7e17d7d729
10 changed files with 141 additions and 45 deletions
+11 -7
View File
@@ -23,7 +23,7 @@ use std::collections::HashMap;
use std::sync::Arc;
use tokio::sync::broadcast::{self, Receiver as B_Receiver};
use tokio::sync::mpsc::{self, Receiver, Sender};
use tracing::{error, warn};
use tracing::{error, info};
use uuid::Uuid;
const MAX_OBJECT_LIST: i32 = 1000;
@@ -246,8 +246,6 @@ impl ECStore {
..Default::default()
};
// warn!("list_objects_generic opts {:?}", &opts);
// use get
if !opts.prefix.is_empty() && opts.limit == 1 && opts.marker.is_none() {
match self
@@ -295,7 +293,7 @@ impl ECStore {
// contextCanceled
let mut get_objects = ObjectInfo::from_meta_cache_entries_sorted(
let mut get_objects = ObjectInfo::from_meta_cache_entries_sorted_infos(
&list_result.entries.unwrap_or_default(),
bucket,
prefix,
@@ -364,10 +362,15 @@ impl ECStore {
max_keys: i32,
) -> Result<ListObjectVersionsInfo> {
if marker.is_none() && version_marker.is_some() {
warn!("inner_list_object_versions: marker is none and version_marker is some");
return Err(StorageError::NotImplemented);
}
let version_marker = if let Some(marker) = version_marker {
Some(Uuid::parse_str(&marker)?)
} else {
None
};
// if marker set, limit +1
let opts = ListPathOptions {
bucket: bucket.to_owned(),
@@ -399,11 +402,12 @@ impl ECStore {
result.forward_past(opts.marker);
}
let mut get_objects = ObjectInfo::from_meta_cache_entries_sorted(
let mut get_objects = ObjectInfo::from_meta_cache_entries_sorted_versions(
&list_result.entries.unwrap_or_default(),
bucket,
prefix,
delimiter.clone(),
version_marker,
)
.await;
@@ -1068,7 +1072,7 @@ async fn merge_entry_channels(
}
},
_ = rx.recv()=>{
warn!("merge_entry_channels rx.recv() cancel");
info!("merge_entry_channels rx.recv() cancel");
return Ok(())
},
}