-
Notifications
You must be signed in to change notification settings - Fork 108
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
Support moving an object #284
Conversation
Hi @yoshidan - do you have any comments on this PR? Is it fit for being merged? |
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 very much. Please confirm one point.
storage/src/http/storage_client.rs
Outdated
let copy_req: CopyObjectRequest = req.clone().into(); | ||
let delete_req: DeleteObjectRequest = req.clone().into(); | ||
let copy_result = self.copy_object(©_req).await; | ||
let result = if copy_result.is_ok() { |
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.
Early returns reduce the number of conditional branches.
let copy_result = self.copy_object(©_req).await?;
let _ = self.delete_object(&delete_req).await?;
Ok(copy_result)
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 @yoshidan , I have actioned it.
Ref: https://cloud.google.com/storage/docs/copying-renaming-moving-objects#permissions-rest
Google provides SDK and CLI command for moving a file, which is basically a
copy
command followed bydelete
.This PR provides a
move
function that wrapscopy
anddelete
function and simulates a move.Thus, providing a single function for library users emulating a
move
, instead of they implementing it repeatedly.