diff options
author | Matt Gumbel <matthew.k.gumbel@intel.com> | 2012-08-30 09:39:36 -0700 |
---|---|---|
committer | gerrit code review <noreply-gerritcodereview@google.com> | 2012-09-06 10:54:46 -0700 |
commit | 2dc810c2e4028878b9c3484866a5973d5c33479d (patch) | |
tree | 567de855659b91a4629d4b555b71612e4c8ed70c | |
parent | bb1b5f5f863fca0e85764f5b35c117f5724d15c0 (diff) | |
download | git-repo-2dc810c2e4028878b9c3484866a5973d5c33479d.tar.gz |
Fix errors when clone.bundle missing on server
Catch curl failures to download clone.bundle; don't let git try to parse
the 404 page as a bundle file (was causing much user confusion).
This should eliminate false error messages from init and sync such as:
error: '.repo/manifests.git/clone.bundle' does not look like a v2 bundle file
fatal: Could not read bundle '.repo/manifests.git/clone.bundle'.
error: RPC failed; result=22, HTTP code = 400
Signed-off-by: Matt Gumbel <matthew.k.gumbel@intel.com>
Change-Id: I7994f7c0baecfb45bb5a5850c48bd2a0ffabe773
-rw-r--r-- | project.py | 16 |
1 files changed, 13 insertions, 3 deletions
@@ -1529,7 +1529,7 @@ class Project(object): | |||
1529 | if os.path.exists(dstPath): | 1529 | if os.path.exists(dstPath): |
1530 | os.remove(dstPath) | 1530 | os.remove(dstPath) |
1531 | 1531 | ||
1532 | cmd = ['curl', '--output', tmpPath, '--netrc', '--location'] | 1532 | cmd = ['curl', '--fail', '--output', tmpPath, '--netrc', '--location'] |
1533 | if quiet: | 1533 | if quiet: |
1534 | cmd += ['--silent'] | 1534 | cmd += ['--silent'] |
1535 | if os.path.exists(tmpPath): | 1535 | if os.path.exists(tmpPath): |
@@ -1549,9 +1549,19 @@ class Project(object): | |||
1549 | except OSError: | 1549 | except OSError: |
1550 | return False | 1550 | return False |
1551 | 1551 | ||
1552 | ok = proc.wait() == 0 | 1552 | curlret = proc.wait() |
1553 | |||
1554 | if curlret == 22: | ||
1555 | # From curl man page: | ||
1556 | # 22: HTTP page not retrieved. The requested url was not found or | ||
1557 | # returned another error with the HTTP error code being 400 or above. | ||
1558 | # This return code only appears if -f, --fail is used. | ||
1559 | if not quiet: | ||
1560 | print >> sys.stderr, "Server does not provide clone.bundle; ignoring." | ||
1561 | return False | ||
1562 | |||
1553 | if os.path.exists(tmpPath): | 1563 | if os.path.exists(tmpPath): |
1554 | if ok and os.stat(tmpPath).st_size > 16: | 1564 | if curlret == 0 and os.stat(tmpPath).st_size > 16: |
1555 | os.rename(tmpPath, dstPath) | 1565 | os.rename(tmpPath, dstPath) |
1556 | return True | 1566 | return True |
1557 | else: | 1567 | else: |