Patchwork lfs: drop a duplicate blob verification method

login
register
mail settings
Submitter Matt Harbison
Date March 31, 2018, 4:16 a.m.
Message ID <9837cda5fd115adecf86.1522469790@Envy>
Download mbox | patch
Permalink /patch/30051/
State Accepted
Headers show

Comments

Matt Harbison - March 31, 2018, 4:16 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@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
Yuya Nishihara - March 31, 2018, 10:09 a.m.
On Sat, 31 Mar 2018 00:16:30 -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@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

Queued, thanks.

Patch

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 '')