mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 18:51:29 +00:00
Don't check bucket permissions if --no-auth.
Checking bucket permissions takes ~400ms. We don't need to do this if --no-auth because we know we won't get a 403 and the 404 check will be handled later when we try to actually download the file. Also, remove the check for a null bucket. This can't happen since we will throw a parser error in the main function before we get to this code. R=iannucci@chromium.org Review URL: https://codereview.chromium.org/772203002 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@293250 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
@@ -110,12 +110,7 @@ class Gsutil(object):
|
||||
return (code, out, err)
|
||||
|
||||
|
||||
def check_bucket_permissions(bucket, gsutil):
|
||||
if not bucket:
|
||||
print >> sys.stderr, 'Missing bucket %s.'
|
||||
return (None, 1)
|
||||
base_url = 'gs://%s' % bucket
|
||||
|
||||
def check_bucket_permissions(base_url, gsutil):
|
||||
code, _, ls_err = gsutil.check_call('ls', base_url)
|
||||
if code != 0:
|
||||
print >> sys.stderr, ls_err
|
||||
@@ -457,10 +452,13 @@ def main(args):
|
||||
parser.error('Output file %s exists and --no_resume is specified.'
|
||||
% options.output)
|
||||
|
||||
base_url = 'gs://%s' % options.bucket
|
||||
|
||||
# Check we have a valid bucket with valid permissions.
|
||||
base_url, code = check_bucket_permissions(options.bucket, gsutil)
|
||||
if code:
|
||||
return code
|
||||
if not options.no_auth:
|
||||
code = check_bucket_permissions(base_url, gsutil, options.no_auth)
|
||||
if code:
|
||||
return code
|
||||
|
||||
return download_from_google_storage(
|
||||
input_filename, base_url, gsutil, options.num_threads, options.directory,
|
||||
|
||||
Reference in New Issue
Block a user