changeset 37217:b00bd974eef5

lfs: drop a duplicate blob verification method
author Matt Harbison <matt_harbison@yahoo.com>
date Sat, 31 Mar 2018 00:02:31 -0400
parents d2bd29dffc6c
children 97ab6f2dc3c3
files hgext/lfs/blobstore.py
diffstat 1 files changed, 3 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- 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 '')