diff options
author | Alex Auvolat <alex@adnab.me> | 2023-10-20 13:37:37 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2023-10-20 13:37:37 +0200 |
commit | 8686cfd0b10a49048021102a08d637b0d4fe6a91 (patch) | |
tree | 1a7d54429686d45d89978f788e5cdb5e8d7805a6 /src/api/s3/put.rs | |
parent | c6cde1f1437a6cab90b22df6fe0641e5ad34c287 (diff) | |
download | garage-8686cfd0b10a49048021102a08d637b0d4fe6a91.tar.gz garage-8686cfd0b10a49048021102a08d637b0d4fe6a91.zip |
s3 api: also ensure increasing timestamps for create_multipart_upload
Diffstat (limited to 'src/api/s3/put.rs')
-rw-r--r-- | src/api/s3/put.rs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/api/s3/put.rs b/src/api/s3/put.rs index 62a1f76a..c4df7561 100644 --- a/src/api/s3/put.rs +++ b/src/api/s3/put.rs @@ -86,11 +86,7 @@ pub(crate) async fn save_stream<S: Stream<Item = Result<Bytes, Error>> + Unpin>( // Generate identity of new version let version_uuid = gen_uuid(); - let version_timestamp = existing_object - .as_ref() - .and_then(|obj| obj.versions().iter().map(|v| v.timestamp).max()) - .map(|t| std::cmp::max(t + 1, now_msec())) - .unwrap_or_else(now_msec); + let version_timestamp = next_timestamp(&existing_object); // If body is small enough, store it directly in the object table // as "inline data". We can then return immediately. @@ -532,3 +528,11 @@ pub(crate) fn get_headers(headers: &HeaderMap<HeaderValue>) -> Result<ObjectVers other, }) } + +pub(crate) fn next_timestamp(existing_object: &Option<Object>) -> u64 { + existing_object + .as_ref() + .and_then(|obj| obj.versions().iter().map(|v| v.timestamp).max()) + .map(|t| std::cmp::max(t + 1, now_msec())) + .unwrap_or_else(now_msec) +} |