diff options
-rwxr-xr-x | lorry | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -477,10 +477,15 @@ class Lorry(cliapp.Application): self.progress('.. checking if we need to fetch %s' % basename) if not os.path.exists(tardest): self.progress('.. attempting to fetch.') - with open(tardest, 'w') as tarfile: - urlfile = urllib2.urlopen(spec['url']) - tarfile.write(urlfile.read()) - urlfile.close() + try: + with open(tardest, 'w') as tarfile: + urlfile = urllib2.urlopen(spec['url']) + tarfile.write(urlfile.read()) + urlfile.close() + except Exception as e: + if os.path.exists(tardest): + os.unlink(tardest) + raise else: self.progress('.. no need to run, nothing to do') return |