Эх сурвалжийг харах

upload_to_google_storage.py: set x-goog-meta-executable during upload instead of using setmeta

This saves a roundtrip, and it only needs upload permissions on buckets,
while setmeta additionally needs update permissions.

No intended behavior change.

Bug: 373661236
Change-Id: Ifce06bd73e59fbad4f584366dd3a6291708ee002
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5935312
Commit-Queue: Nico Weber <thakis@chromium.org>
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Nico Weber 10 сар өмнө
parent
commit
eb732c3c35

+ 10 - 13
upload_to_google_storage.py

@@ -94,7 +94,16 @@ def _upload_worker(thread_num, upload_queue, base_url, gsutil, md5_lock, force,
                         'skipped' % (thread_num, filename))
                         'skipped' % (thread_num, filename))
                     continue
                     continue
         stdout_queue.put('%d> Uploading %s...' % (thread_num, filename))
         stdout_queue.put('%d> Uploading %s...' % (thread_num, filename))
-        gsutil_args = ['-h', 'Cache-Control:public, max-age=31536000', 'cp']
+        gsutil_args = ['-h', 'Cache-Control:public, max-age=31536000']
+
+        # Mark executable files with the header "x-goog-meta-executable: 1"
+        # which the download script will check for to preserve the executable
+        # bit.
+        if not sys.platform.startswith('win'):
+            if os.stat(filename).st_mode & stat.S_IEXEC:
+                gsutil_args += ['-h', 'x-goog-meta-executable:1']
+
+        gsutil_args += ['cp']
         if gzip:
         if gzip:
             gsutil_args.extend(['-z', gzip])
             gsutil_args.extend(['-z', gzip])
         gsutil_args.extend([filename, file_url])
         gsutil_args.extend([filename, file_url])
@@ -104,18 +113,6 @@ def _upload_worker(thread_num, upload_queue, base_url, gsutil, md5_lock, force,
                            (filename, file_url, err)))
                            (filename, file_url, err)))
             continue
             continue
 
 
-        # Mark executable files with the header "x-goog-meta-executable: 1"
-        # which the download script will check for to preserve the executable
-        # bit.
-        if not sys.platform.startswith('win'):
-            if os.stat(filename).st_mode & stat.S_IEXEC:
-                code, _, err = gsutil.check_call_with_retries(
-                    'setmeta', '-h', 'x-goog-meta-executable:1', file_url)
-                if code != 0:
-                    ret_codes.put(
-                        (code,
-                         'Encountered error on setting metadata on %s\n%s' %
-                         (file_url, err)))
 
 
 
 
 def get_targets(args, parser, use_null_terminator):
 def get_targets(args, parser, use_null_terminator):