Skip to content
This repository was archived by the owner on Apr 2, 2026. It is now read-only.

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

Merged
BenWhitehead merged 2 commits intomainfrom
fix-762
Feb 8, 2022
Merged

fix: change CloudStorageFileSystemProvider to throw a FileAlreadyExistsException if copy receives a 412#815
BenWhitehead merged 2 commits intomainfrom
fix-762

Conversation

@BenWhitehead
Copy link
Copy Markdown
Collaborator

Fixes #762

@BenWhitehead BenWhitehead requested a review from a team 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
Copy Markdown
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
Copy Markdown
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 subscribe to this conversation on GitHub. Already have an account? Sign in.

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