From eb732c3c354805488c011a6cb78bebfbfca7c498 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Mon, 21 Oct 2024 14:36:48 +0000 Subject: [PATCH] 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 Reviewed-by: Yiwei Zhang --- upload_to_google_storage.py | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/upload_to_google_storage.py b/upload_to_google_storage.py index b8a7857cfa..81fcfeb78a 100755 --- a/upload_to_google_storage.py +++ b/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)) continue 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: gsutil_args.extend(['-z', gzip]) 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))) 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):