diff --git a/gsutil.py b/gsutil.py index 59a0e1466..52bd5199f 100755 --- a/gsutil.py +++ b/gsutil.py @@ -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.') diff --git a/tests/upload_to_google_storage_unittest.py b/tests/upload_to_google_storage_unittest.py index 4d9bf69dc..5fac9bddd 100755 --- a/tests/upload_to_google_storage_unittest.py +++ b/tests/upload_to_google_storage_unittest.py @@ -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) diff --git a/upload_to_google_storage.py b/upload_to_google_storage.py index 332bb9a47..9b1933d14 100755 --- a/upload_to_google_storage.py +++ b/upload_to_google_storage.py @@ -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])