Skip to content

fix: change CloudStorageFileSystemProvider to throw a FileAlreadyExistsException if copy receives a 412 #815

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

Merged
merged 2 commits into from
Feb 8, 2022

Conversation

BenWhitehead
Copy link
Collaborator

Fixes #762

@BenWhitehead BenWhitehead requested a review from a team as a code owner February 8, 2022 20:56
@product-auto-label product-auto-label bot added the api: storage Issues related to the googleapis/java-storage-nio API. label Feb 8, 2022
Copy link
Contributor

@sydney-munro sydney-munro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. It would be nice if we could get the service team to send out a more helpful error message rather than us making the assumption. Have we put out that feature request?

@BenWhitehead
Copy link
Collaborator Author

In this case there's not something the backend can really do for us. If StandardCopyOption.REPLACE_EXISTING isn't present when the method is called, the FileSystemProvider will explicitly set an expected target generation of 0 (which means expect target to not already exist). If the target already exists, the backend returns 412 to let us know our precondition constraint hasn't been met at which point we can then determine what that means contextually for us. In this case, we would overwrite a "file" we weren't instructed to.

@BenWhitehead BenWhitehead merged commit 33889c3 into main Feb 8, 2022
@BenWhitehead BenWhitehead deleted the fix-762 branch February 8, 2022 22:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the googleapis/java-storage-nio API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Google Storage NIO: FileAlreadyExistsException exception is not honoured when overwriting files
2 participants