[PATCH] lfs: drop a duplicate blob verification method
Matt Harbison
mharbison72 at gmail.com
Sat Mar 31 04:16:30 UTC 2018
# HG changeset patch
# User Matt Harbison <matt_harbison at yahoo.com>
# Date 1522468951 14400
# Sat Mar 31 00:02:31 2018 -0400
# Node ID 9837cda5fd115adecf860d3a97e5a01c07ca72fc
# Parent f1f70b2610da96054c6750122092adbb24e7aea8
lfs: drop a duplicate blob verification method
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 '')
More information about the Mercurial-devel
mailing list