[PATCH 1 of 6] lfs: add a blob verification method to the local store
Yuya Nishihara
yuya at tcha.org
Thu Mar 29 07:57:27 EDT 2018
On Mon, 19 Mar 2018 00:08:24 -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison at yahoo.com>
> # Date 1519360432 18000
> # Thu Feb 22 23:33:52 2018 -0500
> # Node ID 793636c45477f81af6fddacc458979fecc84ae3a
> # Parent 2fc97972bc88809f86bbd91fbfe8582ab59c3ef7
> lfs: add a blob verification method to the local store
>
> A corrupt blob can be signaled through the Batch API response, without actually
> transferring the file. A true/false indicator is slightly easier than
> immediately catching an exception.
>
> diff --git a/hgext/lfs/blobstore.py b/hgext/lfs/blobstore.py
> --- a/hgext/lfs/blobstore.py
> +++ b/hgext/lfs/blobstore.py
> @@ -175,6 +175,17 @@ class local(object):
> _verify(oid, blob)
> return blob
>
> + def verify(self, oid):
> + """Indicate whether or not the hash of the underlying file matches its
> + name."""
> + sha256 = hashlib.sha256()
> +
> + with self.open(oid) as fp:
> + for chunk in util.filechunkiter(fp, size=1048576):
> + sha256.update(chunk)
> +
> + return oid == sha256.hexdigest()
Queued, but can you eliminate copypasta? This is quite similar to
_verifyfile().
More information about the Mercurial-devel
mailing list