sksingh2005 opened a new pull request, #7115:
URL: https://github.com/apache/opendal/pull/7115
# Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and
enhancements. You can link an issue to this PR using the GitHub syntax. For
example `Closes #123` indicates that this PR will close issue #123.
-->
Closes #7090 .
# Rationale for this change
<!--
Why are you proposing this change? If this is already explained clearly in
the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand your
changes and offer better suggestions for fixes.
-->
AWS S3 now supports conditional headers (If-Match and If-None-Match) for
CopyObject and DeleteObject operations, enabling atomic operations and
preventing race conditions in concurrent scenarios. This PR adds support for
these headers to OpenDAL's S3 service, bringing it to feature parity with AWS
S3's latest capabilities and matching the existing implementation in the Azure
Blob service.
# What changes are included in this PR?
<!--
There is no need to duplicate the description in the issue here but it is
sometimes worth providing a summary of the individual changes in this PR.
-->
This PR implements three new conditional operation capabilities for S3:
1. `copy_with_if_not_exists`
- Copy operations that only succeed if the target doesn't exist (using
`If-None-Match: *`)
2. `copy_with_if_match`
- Copy operations that only succeed if the source's ETag matches (using
`If-Match: <etag>`)
3. `delete_with_if_match`
- Delete operations that only succeed if the file's ETag matches (using`
If-Match: <etag>`)
### Core Changes:
- Added
[copy_with_if_match](cci:1://file://wsl.localhost/Ubuntu-22.04/home/sayshank/projects/opendal/core/tests/behavior/async_copy.rs:361:0-387:1)
and
[delete_with_if_match](cci:1://file://wsl.localhost/Ubuntu-22.04/home/sayshank/projects/opendal/core/tests/behavior/async_delete.rs:414:0-439:1)
capability flags
- Extended
[OpCopy](cci:2://file://wsl.localhost/Ubuntu-22.04/home/sayshank/projects/opendal/core/core/src/raw/ops.rs:891:0-894:1)
and
[OpDelete](cci:2://file://wsl.localhost/Ubuntu-22.04/home/sayshank/projects/opendal/core/core/src/raw/ops.rs:43:0-47:1)
with
[if_match](cci:1://file://wsl.localhost/Ubuntu-22.04/home/sayshank/projects/opendal/core/core/src/raw/ops.rs:85:4-88:5)
fields
- Added
[if_match](cci:1://file://wsl.localhost/Ubuntu-22.04/home/sayshank/projects/opendal/core/core/src/raw/ops.rs:85:4-88:5)
to
[CopyOptions](cci:2://file://wsl.localhost/Ubuntu-22.04/home/sayshank/projects/opendal/core/core/src/types/options.rs:525:0-549:1)
and
[DeleteOptions](cci:2://file://wsl.localhost/Ubuntu-22.04/home/sayshank/projects/opendal/core/core/src/types/options.rs:24:0-40:1)
- Exposed
[if_match()](cci:1://file://wsl.localhost/Ubuntu-22.04/home/sayshank/projects/opendal/core/core/src/raw/ops.rs:85:4-88:5)
methods in `FutureCopy` and `FutureDelete` for user-facing API
**S3 Service Implementation:**
- Updated S3 backend to advertise new capabilities
- Implemented conditional headers in
[s3_copy_object()](cci:1://file://wsl.localhost/Ubuntu-22.04/home/sayshank/projects/opendal/core/services/s3/src/core.rs:632:4-701:5)
and
[s3_delete_object()](cci:1://file://wsl.localhost/Ubuntu-22.04/home/sayshank/projects/opendal/core/services/s3/src/core.rs:594:4-630:5)
- Added proper header handling for `If-Match` and `If-None-Match`
**Testing:**
- Added 4 new behavior tests covering success and failure scenarios
- Tests follow existing OpenDAL patterns and are registered in the test suite
# Are there any user-facing changes?
<!--
If there are user-facing changes then we may require documentation to be
updated before approving the PR.
-->
**Yes**, this PR adds new user-facing methods:
```rust
// Copy with If-Match header
op.copy_with("source", "target")
.if_match("\"etag-value\"")
.await?;
// Delete with If-Match header
op.delete_with("path")
.if_match("\"etag-value\"")
.await?;
```
<!---
If there are any breaking changes to public APIs, please add the
`breaking-changes` label.
-->
# AI Usage Statement
<!--
If you are using AI tools to build this PR, please include a statement
specifying the tool and models you are using.
-->
This PR was implemented with assistance from **Claude Sonnet 4.5** through
the Antigravity coding assistant. The AI helped with:
- Test case design based on existing behavior tests
All code was reviewed, tested, and validated by the human contributor.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]