diff options
| -rw-r--r-- | project.py | 13 |
1 files changed, 12 insertions, 1 deletions
| @@ -1804,7 +1804,7 @@ class Project(object): | |||
| 1804 | return False | 1804 | return False |
| 1805 | 1805 | ||
| 1806 | if os.path.exists(tmpPath): | 1806 | if os.path.exists(tmpPath): |
| 1807 | if curlret == 0 and os.stat(tmpPath).st_size > 16: | 1807 | if curlret == 0 and self._IsValidBundle(tmpPath): |
| 1808 | os.rename(tmpPath, dstPath) | 1808 | os.rename(tmpPath, dstPath) |
| 1809 | return True | 1809 | return True |
| 1810 | else: | 1810 | else: |
| @@ -1813,6 +1813,17 @@ class Project(object): | |||
| 1813 | else: | 1813 | else: |
| 1814 | return False | 1814 | return False |
| 1815 | 1815 | ||
| 1816 | def _IsValidBundle(self, path): | ||
| 1817 | try: | ||
| 1818 | with open(path) as f: | ||
| 1819 | if f.read(16) == '# v2 git bundle\n': | ||
| 1820 | return True | ||
| 1821 | else: | ||
| 1822 | print("Invalid clone.bundle file; ignoring.", file=sys.stderr) | ||
| 1823 | return False | ||
| 1824 | except OSError: | ||
| 1825 | return False | ||
| 1826 | |||
| 1816 | def _Checkout(self, rev, quiet=False): | 1827 | def _Checkout(self, rev, quiet=False): |
| 1817 | cmd = ['checkout'] | 1828 | cmd = ['checkout'] |
| 1818 | if quiet: | 1829 | if quiet: |
