Commit d3e713bf authored by ojan@chromium.org's avatar ojan@chromium.org

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
parent 0c806a71
......@@ -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,
......
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