Mercurial > hg
diff hgext/lfs/blobstore.py @ 35553:a77418095530
lfs: remove the verification option when writing to the local store
This partially reverts 417e8e040102 and bb6a80fc969a. But since there's now a
dedicated download function, there's no functional change. The last sentence in
the commit message of the latter is wrong- write() didn't need the one time hash
check if verification wasn't requested. I suspect I missed 'read()' in there
("... but _read()_ also needs to do a one time check..."), because that did fail
without the hash check before linking to the usercache. The write() method
simply took the same check for consistency.
While here, clarify that the write() method is *only* for storing content
directly from filelog, which has already checked the hash.
If someone can come up with a way to bridge the differences between writing to a
file and sending a urlreq.request across the wire, we can create an upload()
function and cleanup read() in a similar way. About the only common thread I
see is an open() that verifies the content before returning a file descriptor.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Sun, 07 Jan 2018 01:14:52 -0500 |
parents | fd610befc37f |
children | ebf14075a5c1 |
line wrap: on
line diff
--- a/hgext/lfs/blobstore.py Thu Dec 21 21:20:00 2017 -0500 +++ b/hgext/lfs/blobstore.py Sun Jan 07 01:14:52 2018 -0500 @@ -134,20 +134,20 @@ self.ui.note(_('lfs: adding %s to the usercache\n') % oid) lfutil.link(self.vfs.join(oid), self.cachevfs.join(oid)) - def write(self, oid, data, verify=True): - """Write blob to local blobstore.""" - if verify: - _verify(oid, data) + def write(self, oid, data): + """Write blob to local blobstore. + This should only be called from the filelog during a commit or similar. + As such, there is no need to verify the data. Imports from a remote + store must use ``download()`` instead.""" with self.vfs(oid, 'wb', atomictemp=True) as fp: fp.write(data) # XXX: should we verify the content of the cache, and hardlink back to # the local store on success, but truncate, write and link on failure? if not self.cachevfs.exists(oid): - if verify or hashlib.sha256(data).hexdigest() == oid: - self.ui.note(_('lfs: adding %s to the usercache\n') % oid) - lfutil.link(self.vfs.join(oid), self.cachevfs.join(oid)) + self.ui.note(_('lfs: adding %s to the usercache\n') % oid) + lfutil.link(self.vfs.join(oid), self.cachevfs.join(oid)) def read(self, oid, verify=True): """Read blob from local blobstore."""