##// END OF EJS Templates
lfs: introduce a localstore method for downloading from remote stores...
Matt Harbison -
r35565:fa9dd53e default
parent child Browse files
Show More
@@ -114,6 +114,26 b' class local(object):'
114
114
115 return self.vfs(oid, 'rb')
115 return self.vfs(oid, 'rb')
116
116
117 def download(self, oid, src):
118 """Read the blob from the remote source in chunks, verify the content,
119 and write to this local blobstore."""
120 sha256 = hashlib.sha256()
121
122 with self.vfs(oid, 'wb', atomictemp=True) as fp:
123 for chunk in util.filechunkiter(src, size=1048576):
124 fp.write(chunk)
125 sha256.update(chunk)
126
127 realoid = sha256.hexdigest()
128 if realoid != oid:
129 raise error.Abort(_('corrupt remote lfs object: %s') % oid)
130
131 # XXX: should we verify the content of the cache, and hardlink back to
132 # the local store on success, but truncate, write and link on failure?
133 if not self.cachevfs.exists(oid):
134 self.ui.note(_('lfs: adding %s to the usercache\n') % oid)
135 lfutil.link(self.vfs.join(oid), self.cachevfs.join(oid))
136
117 def write(self, oid, data, verify=True):
137 def write(self, oid, data, verify=True):
118 """Write blob to local blobstore."""
138 """Write blob to local blobstore."""
119 if verify:
139 if verify:
General Comments 0
You need to be logged in to leave comments. Login now