-
Notifications
You must be signed in to change notification settings - Fork 24
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
actions: add CopyObject action #47
base: main
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## main #47 +/- ##
==========================================
- Coverage 91.53% 91.12% -0.42%
==========================================
Files 26 27 +1
Lines 1300 1352 +52
==========================================
+ Hits 1190 1232 +42
- Misses 110 120 +10
Continue to review full report at Codecov.
|
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.
Thank you for your job :)
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 the PR! I left a change for the implementation and a nitpick for the docs.
src/actions/copy_object.rs
Outdated
self.headers.iter(), | ||
), | ||
None => { | ||
url.query_pairs_mut().append_pair( |
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.
This should instead call crate::signing::util::add_query_params(url, self.query.iter())
so that any custom query parameters are also included.
Example from another action:
rusty-s3/src/actions/list_objects_v2.rs
Line 149 in 9e10f5f
None => crate::signing::util::add_query_params(url, self.query.iter()), |
src/actions/copy_object.rs
Outdated
/// Create a copy of an object that is already stored in S3, using a `PUT` request. | ||
/// | ||
/// Find out more about CopyObject from the [AWS API Reference][api] | ||
/// | ||
/// [api]: https://docs.aws.amazon.com/AmazonS3/latest/API/API_CopyObject.html |
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.
Some actions also mention a few important pieces of information I found from the AWS docs, for this one I think it would be worth to briefly mention some of the footguns with this method:
- only objects up to 5 GB can be copied using this method
- even if the server returns a 200 response the copy might have failed
The time crate bumped MSRV again @guerinoni 🙄 |
@Sporif also rebase on |
src/actions/copy_object.rs
Outdated
query.insert( | ||
"x-amz-copy-source", | ||
format!("{}/{}", bucket.name(), src_object), | ||
); |
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.
Should this use SortingIterator
while signing to save a Map allocation, like here?
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.
By prefixing the current bucket name, this action does not allow copying from a different bucket.
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.
Should this use
SortingIterator
while signing to save a Map allocation, like here?
Sure, sounds like a good use for it.
By prefixing the current bucket name, this action does not allow copying from a different bucket.
We could take both a src_bucket
and a dst_bucket
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.
Taking a Bucket
is unnecessarily involved, as you need to pass connection details for bucket construction which will go completely unused. How about taking the raw source string, and having two separate functions on Bucket
, e.g.:
Bucket::copy_object
would prepend the current bucket name,Bucket::copy_object_from_bucket
would pass the source string as-is, and require the caller to prepend a (potentially different) bucket name
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.
Sounds good
Implemented the changes as best I could, but there's one big problem I hadn't noticed before: the copy doesn't actually work (at least on minio) as the copied object is empty. No idea why. |
Ok so I'm really dumb, none of this is needed, |
I think it'd be still worth it to have it as a separate method. I'll try looking into why the test fails |
No description provided.