hgext/lfs/blobstore.py
changeset 39457 a913d2892e17
parent 39389 b26350d9d7b5
child 39777 b63dee7bd0d9
--- 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?