Skip to content
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

Merged
merged 7 commits into from
Jul 22, 2024
Merged

Conversation

pratimsc
Copy link
Contributor

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 by delete.

This PR provides a move function that wraps copy and delete function and simulates a move.
Thus, providing a single function for library users emulating a move, instead of they implementing it repeatedly.

@pratimsc pratimsc changed the title Support moving of object Support moving an object Jul 16, 2024
@pratimsc
Copy link
Contributor Author

Hi @yoshidan - do you have any comments on this PR? Is it fit for being merged?

Copy link
Owner

@yoshidan yoshidan left a 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.

let copy_req: CopyObjectRequest = req.clone().into();
let delete_req: DeleteObjectRequest = req.clone().into();
let copy_result = self.copy_object(&copy_req).await;
let result = if copy_result.is_ok() {
Copy link
Owner

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(&copy_req).await?;
let _ = self.delete_object(&delete_req).await?;
Ok(copy_result)

Copy link
Contributor Author

@pratimsc pratimsc Jul 19, 2024

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.

@pratimsc pratimsc requested a review from yoshidan July 19, 2024 22:06
@yoshidan yoshidan added the safe to test safe to test label Jul 22, 2024
@yoshidan yoshidan merged commit 39a0832 into yoshidan:main Jul 22, 2024
8 of 9 checks passed
@pratimsc pratimsc deleted the feature/move-object branch July 22, 2024 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
safe to test safe to test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants