-
Notifications
You must be signed in to change notification settings - Fork 404
feat: support conditional writes #409
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I will review this PR in a few days. |
@guojidan If the code review is complete and all aspects of the functionality are ready, you can merge the feature. |
crates/ecstore/src/set_disk.rs
Outdated
@@ -3218,6 +3219,42 @@ impl SetDisks { | |||
obj?; | |||
Ok(()) | |||
} | |||
|
|||
async fn check_write_precondition(&self, bucket: &str, object: &str, mut opts: ObjectOptions) -> Option<StorageError> { | |||
let http_preconditions = opts.http_preconditions.unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do not use unwarp()
crates/ecstore/src/set_disk.rs
Outdated
@@ -3218,6 +3219,42 @@ impl SetDisks { | |||
obj?; | |||
Ok(()) | |||
} | |||
|
|||
async fn check_write_precondition(&self, bucket: &str, object: &str, mut opts: ObjectOptions) -> Option<StorageError> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should use opts: &ObjectOptions
, and later use let opts = opts.clone()
, because we do not intend to modify the incoming opts
itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your advice! I've fixed them
LGTM,
|
I'll add the tests sometime this week, kind of busy today~ |
I've added some e2e tests~ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* 'main' of github.com:rustfs/rustfs: feat: support conditional writes (#409)
Type of Change
Related Issues
#406
Summary of Changes
When executing
PutObject
andCompleteMultipartUpload
, if theIf-None-Match
orIf-Match
header is set, check the etag of the object before proceeding. The implementation strategy comes from MinIO.I've done some tests with the following settings:
PutObject
andCompleteMultipartUpload
Looks good for now.
Any further tests and comments are welcome!
Checklist
make pre-commit
Impact
Additional Notes
Thank you for your contribution! Please ensure your PR follows the community standards (CODE_OF_CONDUCT.md) and sign the CLA if this is your first contribution.