Mercurial > public > mercurial-scm > hg-stable
diff hgext/lfs/blobstore.py @ 39474:a913d2892e17
lfs: ensure the blob is linked to the remote store on skipped uploads
I noticed a "missing" blob when pushing two repositories with common blobs to a
fresh server, and then running `hg verify` as a user different from the one
running the web server. When pushing the second repo, several of the blobs
already existed in the user cache, so the server indicated to the client that it
doesn't need to upload the blobs. That's good enough for the web server process
to serve up in the future. But a different user has a different cache by
default, so verify complains that `lfs.url` needs to be set, because it wants to
fetch the missing blobs.
Aside from that corner case, it's better to keep all of the blobs in the repo
whenever possible. Especially since the largefiles wiki says the user cache can
be deleted at any time to reclaim disk space- users switching over may have the
same expectations.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Thu, 06 Sep 2018 00:51:21 -0400 |
parents | b26350d9d7b5 |
children | b63dee7bd0d9 |
line wrap: on
line diff
--- a/hgext/lfs/blobstore.py Tue Sep 04 22:29:38 2018 -0400 +++ b/hgext/lfs/blobstore.py Thu Sep 06 00:51:21 2018 -0400 @@ -168,6 +168,20 @@ self._linktousercache(oid) + def linkfromusercache(self, oid): + """Link blobs found in the user cache into this store. + + The server module needs to do this when it lets the client know not to + upload the blob, to ensure it is always available in this store. + Normally this is done implicitly when the client reads or writes the + blob, but that doesn't happen when the server tells the client that it + already has the blob. + """ + if (not isinstance(self.cachevfs, nullvfs) + and not self.vfs.exists(oid)): + self.ui.note(_('lfs: found %s in the usercache\n') % oid) + lfutil.link(self.cachevfs.join(oid), self.vfs.join(oid)) + def _linktousercache(self, oid): # 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?