Commit c1fd44b0 authored by Josip Sokcevic's avatar Josip Sokcevic Committed by LUCI CQ

Set cache-control when uploading to google storage

R=gavinmak@google.com

Bug: 585752
Change-Id: I25ece89abd09ad509807a7db0403bac0f5ebdd4e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3171825
Auto-Submit: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Gavin Mak <gavinmak@google.com>
Reviewed-by: 's avatarGavin Mak <gavinmak@google.com>
parent 6550ec91
......@@ -177,7 +177,8 @@ def run_gsutil(target, args, clean=False):
def parse_args():
bin_dir = os.environ.get('DEPOT_TOOLS_GSUTIL_BIN_DIR', DEFAULT_BIN_DIR)
parser = argparse.ArgumentParser()
# Help is disabled as it conflicts with gsutil -h, which controls headers.
parser = argparse.ArgumentParser(add_help=False)
parser.add_argument('--clean', action='store_true',
help='Clear any existing gsutil package, forcing a new download.')
......
......@@ -68,8 +68,8 @@ class UploadTests(unittest.TestCase):
[('check_call',
('ls', '%s/%s' % (self.base_url, self.lorem_ipsum_sha1))),
('check_call',
('cp', '-z', 'txt', filenames[0],
'%s/%s' % (self.base_url, self.lorem_ipsum_sha1)))])
('-h', 'Cache-Control:public, max-age=31536000', 'cp', '-z', 'txt',
filenames[0], '%s/%s' % (self.base_url, self.lorem_ipsum_sha1)))])
self.assertTrue(os.path.exists(output_filename))
self.assertEqual(
open(output_filename, 'rb').read().decode(),
......@@ -157,12 +157,10 @@ class UploadTests(unittest.TestCase):
filenames, self.base_url, self.gsutil, False, False, 1, True, None)
self.assertEqual(
self.gsutil.history,
[('check_call',
('ls', '%s/%s' % (self.base_url, fake_hash))),
('check_call',
('ls', '-L', '%s/%s' % (self.base_url, fake_hash))),
('check_call',
('cp', filenames[0], '%s/%s' % (self.base_url, fake_hash)))])
[('check_call', ('ls', '%s/%s' % (self.base_url, fake_hash))),
('check_call', ('ls', '-L', '%s/%s' % (self.base_url, fake_hash))),
('check_call', ('-h', 'Cache-Control:public, max-age=31536000', 'cp',
filenames[0], '%s/%s' % (self.base_url, fake_hash)))])
self.assertEqual(
open(output_filename, 'rb').read().decode(), fake_hash)
os.remove(output_filename)
......
......@@ -100,7 +100,7 @@ def _upload_worker(
continue
stdout_queue.put('%d> Uploading %s...' % (
thread_num, filename))
gsutil_args = ['cp']
gsutil_args = ['-h', 'Cache-Control:public, max-age=31536000', 'cp']
if gzip:
gsutil_args.extend(['-z', gzip])
gsutil_args.extend([filename, file_url])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment