diff --git a/hgext/lfs/blobstore.py b/hgext/lfs/blobstore.py --- a/hgext/lfs/blobstore.py +++ b/hgext/lfs/blobstore.py @@ -316,8 +316,9 @@ class _gitlfsremote(object): 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 @@ def _verify(oid, content): 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 '')