Skip to content

Commit

Permalink
Add exception to correctness checks for S3 wildcard if-none-match
Browse files Browse the repository at this point in the history
  • Loading branch information
gruuya committed Jan 3, 2025
1 parent c866d4b commit 291404e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
16 changes: 10 additions & 6 deletions core/src/layers/correctness_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,16 @@ impl<A: Access> LayeredAccess for CorrectnessAccessor<A> {
"if_not_exists",
));
}
if args.if_none_match().is_some() && !capability.write_with_if_none_match {
return Err(new_unsupported_error(
self.info.as_ref(),
Operation::Write,
"if_none_match",
));
if let Some(if_none_match) = args.if_none_match() {
// AWS S3 supports only wildcard (every resource) matching
let is_s3_wildcard_match = self.info.scheme() == Scheme::S3 && if_none_match == "*";
if !is_s3_wildcard_match || !capability.write_with_if_none_match {
return Err(new_unsupported_error(
self.info.as_ref(),
Operation::Write,
"if_none_match",
));
}
}

self.inner.write(path, args).await
Expand Down
2 changes: 1 addition & 1 deletion core/src/services/s3/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ impl S3Core {
req = req.header(IF_MATCH, if_match);
}

if args.if_not_exists() {
if args.if_not_exists() || args.if_none_match() == Some("*") {
req = req.header(IF_NONE_MATCH, "*");
}

Expand Down

0 comments on commit 291404e

Please sign in to comment.