Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/aws/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,13 @@ impl ObjectStore for AmazonS3 {
(PutMode::Overwrite, _) => request.idempotent(true).do_put().await,
(PutMode::Create, S3ConditionalPut::Disabled) => Err(Error::NotImplemented),
(PutMode::Create, S3ConditionalPut::ETagMatch) => {
match request.header(&IF_NONE_MATCH, "*").do_put().await {
match request
.header(&IF_NONE_MATCH, "*")
// Conditional put with If-None-Match is idempotent.
.idempotent(true)
.do_put()
.await
{
// Technically If-None-Match should return NotModified but some stores,
// such as R2, instead return PreconditionFailed
// https://developers.cloudflare.com/r2/api/s3/extensions/#conditional-operations-in-putobject
Expand All @@ -205,6 +211,8 @@ impl ObjectStore for AmazonS3 {
S3ConditionalPut::ETagMatch => {
match request
.header(&IF_MATCH, etag.as_str())
// Conditional PUTs with If-Match are idempotent.
.idempotent(true)
// Real S3 will occasionally report 409 Conflict
// if there are concurrent `If-Match` requests
// in flight, so we need to be prepared to retry
Expand Down
Loading