Delete corrupt cache entries from ~/.gerritcodereview/buck-cache
If the SHA-1 does not match the downloaded file content, delete the file from the cache. This allows a user to fix whatever connectivity problem led to the corruption and re-run buck build to download the correct content. Change-Id: I2f72fb2b187675ec9d5cda650d8982bc93a00189
This commit is contained in:
parent
e1f8288fc7
commit
eb2eeec491
@ -17,7 +17,7 @@ from __future__ import print_function
|
||||
|
||||
from hashlib import sha1
|
||||
from optparse import OptionParser
|
||||
from os import link, makedirs, path, symlink
|
||||
from os import link, makedirs, path, remove, symlink
|
||||
import shutil
|
||||
from subprocess import check_call, CalledProcessError
|
||||
from sys import stderr
|
||||
@ -135,12 +135,15 @@ if not path.exists(cache_ent):
|
||||
if args.v:
|
||||
have = hashfile(cache_ent)
|
||||
if args.v != have:
|
||||
o = cache_ent[len(root_dir) + 1:]
|
||||
print((
|
||||
'%s:\n' +
|
||||
'expected %s\n' +
|
||||
'received %s\n' +
|
||||
' %s\n') % (src_url, args.v, have, o), file=stderr)
|
||||
'received %s\n') % (src_url, args.v, have), file=stderr)
|
||||
try:
|
||||
remove(cache_ent)
|
||||
except OSError as err:
|
||||
if path.exists(cache_ent):
|
||||
print('error removing %s: %s' % (cache_ent, err), file=stderr)
|
||||
exit(1)
|
||||
|
||||
exclude = []
|
||||
|
Loading…
Reference in New Issue
Block a user