--- a/hgext/lfs/blobstore.py Fri Mar 30 23:32:06 2018 -0400
+++ b/hgext/lfs/blobstore.py Sat Mar 31 00:02:31 2018 -0400
@@ -316,8 +316,9 @@
request = util.urlreq.request(href)
if action == 'upload':
# If uploading blobs, read data from local blobstore.
- with localstore.open(oid) as fp:
- _verifyfile(oid, fp)
+ if not localstore.verify(oid):
+ raise error.Abort(_('detected corrupt lfs object: %s') % oid,
+ hint=_('run hg verify'))
request.data = filewithprogress(localstore.open(oid), None)
request.get_method = lambda: 'PUT'
@@ -491,18 +492,6 @@
raise error.Abort(_('detected corrupt lfs object: %s') % oid,
hint=_('run hg verify'))
-def _verifyfile(oid, fp):
- sha256 = hashlib.sha256()
- while True:
- data = fp.read(1024 * 1024)
- if not data:
- break
- sha256.update(data)
- realoid = sha256.hexdigest()
- if realoid != oid:
- raise error.Abort(_('detected corrupt lfs object: %s') % oid,
- hint=_('run hg verify'))
-
def remote(repo):
"""remotestore factory. return a store in _storemap depending on config"""
url = util.url(repo.ui.config('lfs', 'url') or '')