-
Notifications
You must be signed in to change notification settings - Fork 155
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
feat(storage): add arguments for *GenerationMatch uploading options #111
Conversation
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.
Documentation nit.
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.
LGTM, ty!
👍 Thanks to @HollayHorvath and @frankyn! The code to create a directory placeholder changes from blob = bucket.blob(name)
if not blob.exists():
blob.upload_from_string(b'', content_type=OCTET_STREAM) to blob = bucket.blob(name)
try:
blob.upload_from_string(
b'', content_type=OCTET_STREAM, if_generation_match=0)
except PreconditionFailed:
pass because, as the doc says, "Setting to 0 makes the operation succeed only if there are no live versions of the blob." In a handful of timings, the new code saved more than half the didn't-exist time and a bit of the already-exists time (although that might be measurement noise). |
…oogleapis#111) * feat(storage): add arguments for *GenerationMatch uploading options * add unit tests changes * change args names in unit tests * add unit tests for _do_multipart_upload() * add unit tests for _initiate_resumable_upload() * add args translation into unit tests urls * update args docs
…oogleapis#111) * feat(storage): add arguments for *GenerationMatch uploading options * add unit tests changes * change args names in unit tests * add unit tests for _do_multipart_upload() * add unit tests for _initiate_resumable_upload() * add args translation into unit tests urls * update args docs
These changes were originally made in another PR. Here is the version with changes requested by reviews.
Closes #16