diff options
author | Alex Auvolat <alex@adnab.me> | 2020-05-01 15:52:35 +0000 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2020-05-01 15:52:35 +0000 |
commit | d867bbcfb513761c6709347509b8438cfdf408c7 (patch) | |
tree | 2eda9af740d620eb4b731012e1dda2e4040a895d /src/api/s3_list.rs | |
parent | 33249717010b1173fc28ba188e5fe6d580fbf393 (diff) | |
download | garage-d867bbcfb513761c6709347509b8438cfdf408c7.tar.gz garage-d867bbcfb513761c6709347509b8438cfdf408c7.zip |
Implement DeleteObjects
Diffstat (limited to 'src/api/s3_list.rs')
-rw-r--r-- | src/api/s3_list.rs | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/api/s3_list.rs b/src/api/s3_list.rs index df792da2..d4d8161e 100644 --- a/src/api/s3_list.rs +++ b/src/api/s3_list.rs @@ -30,34 +30,38 @@ pub async fn handle_list( let mut result_keys = BTreeMap::<String, ListResultInfo>::new(); let mut result_common_prefixes = BTreeSet::<String>::new(); - let mut truncated = true; let mut next_chunk_start = marker.unwrap_or(prefix).to_string(); debug!("List request: `{}` {} `{}`", delimiter, max_keys, prefix); - while result_keys.len() + result_common_prefixes.len() < max_keys && truncated { + let truncated; + 'query_loop: loop { let objects = garage .object_table .get_range( &bucket.to_string(), Some(next_chunk_start.clone()), Some(()), - max_keys, + max_keys + 1, ) .await?; debug!( "List: get range {} (max {}), results: {}", next_chunk_start, - max_keys, + max_keys + 1, objects.len() ); for object in objects.iter() { if !object.key.starts_with(prefix) { truncated = false; - break; + break 'query_loop; } if let Some(version) = object.versions().iter().find(|x| x.is_data()) { + if result_keys.len() + result_common_prefixes.len() >= max_keys { + truncated = true; + break 'query_loop; + } let common_prefix = if delimiter.len() > 0 { let relative_key = &object.key[prefix.len()..]; match relative_key.find(delimiter) { @@ -83,8 +87,9 @@ pub async fn handle_list( }; } } - if objects.len() < max_keys { - truncated = false; + if objects.len() < max_keys + 1 { + truncated = false; + break 'query_loop; } if objects.len() > 0 { next_chunk_start = objects[objects.len() - 1].key.clone(); |