Force gs.py to use generation rather than sequence-match.
Currently no consuming code has been found sans unittests so
this is reasonably safe. For existing usage where it was
just a fail-if-exists check, the change restores functionality;
for any sequence tracking code (which I've yet to find sans locks
that don't use this pathway) it will break; it was broken via
the referenced bug anyways, thus is decided to move forward with.
BUG=chromium-os:37718
TEST=validation of the header, but nothing beyond that; TBR.
Change-Id: Ic1d42b0e9dca1be60105f86aa0eaaed6020e0f40
Previous-Reviewed-on: https://gerrit.chromium.org/gerrit/40929
(cherry picked from commit 114efcca9aca3e36ccac964b4b4a3768346ab799)
Previous-Reviewed-on: https://gerrit.chromium.org/gerrit/41106
Commit-Queue: Jon Salz <jsalz@chromium.org>
(cherry picked from commit e7089f2f6c3b557fc8aa83f2c8e3d11d8037fb4f)
Reviewed-on: https://gerrit.chromium.org/gerrit/41184
Reviewed-by: David James <davidjames@chromium.org>
Tested-by: David James <davidjames@chromium.org>
diff --git a/lib/gs.py b/lib/gs.py
index 79cd102..8dc8cf5 100644
--- a/lib/gs.py
+++ b/lib/gs.py
@@ -105,8 +105,11 @@
filename: If given, the filename to place the content at; if not given,
it's discerned from basename(local_path).
acl: If given, a canned ACL.
- version: If given, the sequence-number; essentially the version we intend
- to replace/update. This is useful for distributed reasons- for example,
+ version: If given, the generation; essentially the timestamp of the last
+ update. Note this is not the same as sequence-number; it's
+ monotonically increasing bucket wide rather than reset per file.
+ The usage of this is if we intend to replace/update only if the version
+ is what we expect. This is useful for distributed reasons- for example,
to ensure you don't overwrite someone else's creation, a version of
0 states "only update if no version exists".
"""
@@ -148,8 +151,11 @@
dest_path: Fully qualified local path or full gs:// path of the dest
file.
acl: One of the google storage canned_acls to apply.
- version: If given, the sequence-number; essentially the version we intend
- to replace/update. This is useful for distributed reasons- for example,
+ version: If given, the generation; essentially the timestamp of the last
+ update. Note this is not the same as sequence-number; it's
+ monotonically increasing bucket wide rather than reset per file.
+ The usage of this is if we intend to replace/update only if the version
+ is what we expect. This is useful for distributed reasons- for example,
to ensure you don't overwrite someone else's creation, a version of
0 states "only update if no version exists".
@@ -161,7 +167,7 @@
cmd, headers = [], []
if version is not None:
- headers = ['x-goog-if-sequence-number-match:%d' % version]
+ headers = ['x-goog-if-generation-match:%d' % version]
cmd.append('cp')