##// END OF EJS Templates
lfs: add a method to the local blobstore to convert OIDs to file paths...
Matt Harbison -
r44745:06de4a67 default
parent child Browse files
Show More
@@ -139,6 +139,17 b' class local(object):'
139 def open(self, oid):
139 def open(self, oid):
140 """Open a read-only file descriptor to the named blob, in either the
140 """Open a read-only file descriptor to the named blob, in either the
141 usercache or the local store."""
141 usercache or the local store."""
142 return open(self.path(oid), b'rb')
143
144 def path(self, oid):
145 """Build the path for the given blob ``oid``.
146
147 If the blob exists locally, the path may point to either the usercache
148 or the local store. If it doesn't, it will point to the local store.
149 This is meant for situations where existing code that isn't LFS aware
150 needs to open a blob. Generally, prefer the ``open`` method on this
151 class.
152 """
142 # The usercache is the most likely place to hold the file. Commit will
153 # The usercache is the most likely place to hold the file. Commit will
143 # write to both it and the local store, as will anything that downloads
154 # write to both it and the local store, as will anything that downloads
144 # the blobs. However, things like clone without an update won't
155 # the blobs. However, things like clone without an update won't
@@ -146,9 +157,9 b' class local(object):'
146 # the usercache is the only place it _could_ be. If not present, the
157 # the usercache is the only place it _could_ be. If not present, the
147 # missing file msg here will indicate the local repo, not the usercache.
158 # missing file msg here will indicate the local repo, not the usercache.
148 if self.cachevfs.exists(oid):
159 if self.cachevfs.exists(oid):
149 return self.cachevfs(oid, b'rb')
160 return self.cachevfs.join(oid)
150
161
151 return self.vfs(oid, b'rb')
162 return self.vfs.join(oid)
152
163
153 def download(self, oid, src, content_length):
164 def download(self, oid, src, content_length):
154 """Read the blob from the remote source in chunks, verify the content,
165 """Read the blob from the remote source in chunks, verify the content,
General Comments 0
You need to be logged in to leave comments. Login now