[PATCH 3 of 3] lfs: add an optional size limit when downloading a blob
Matt Harbison
mharbison72 at gmail.com
Thu Feb 22 01:02:43 EST 2018
# HG changeset patch
# User Matt Harbison <matt_harbison at yahoo.com>
# Date 1519277492 18000
# Thu Feb 22 00:31:32 2018 -0500
# Node ID 36bfb2fc865b1d6024b943bece407970c4d61112
# Parent 7a6042e238b7a90ce1d158395c42937cb0f7298c
lfs: add an optional size limit when downloading a blob
The server hangs when it tries to read more than Content-Length bytes in the PUT
handler.
diff --git a/hgext/lfs/blobstore.py b/hgext/lfs/blobstore.py
--- a/hgext/lfs/blobstore.py
+++ b/hgext/lfs/blobstore.py
@@ -114,13 +114,13 @@
return self.vfs(oid, 'rb')
- def download(self, oid, src):
+ def download(self, oid, src, limit=None):
"""Read the blob from the remote source in chunks, verify the content,
and write to this local blobstore."""
sha256 = hashlib.sha256()
with self.vfs(oid, 'wb', atomictemp=True) as fp:
- for chunk in util.filechunkiter(src, size=1048576):
+ for chunk in util.filechunkiter(src, size=1048576, limit=limit):
fp.write(chunk)
sha256.update(chunk)
More information about the Mercurial-devel
mailing list