##// END OF EJS Templates
largefiles: remove blecch from lfutil.copyandhash - don't close the passed fd
Mads Kiilerich -
r19002:5083baa6 default
parent child Browse files
Show More
@@ -289,18 +289,11 b' def writestandin(repo, standin, hash, ex'
289 289
290 290 def copyandhash(instream, outfile):
291 291 '''Read bytes from instream (iterable) and write them to outfile,
292 computing the SHA-1 hash of the data along the way. Close outfile
293 when done and return the hash.'''
292 computing the SHA-1 hash of the data along the way. Return the hash.'''
294 293 hasher = util.sha1('')
295 294 for data in instream:
296 295 hasher.update(data)
297 296 outfile.write(data)
298
299 # Blecch: closing a file that somebody else opened is rude and
300 # wrong. But it's so darn convenient and practical! After all,
301 # outfile was opened just to copy and hash.
302 outfile.close()
303
304 297 return hasher.hexdigest()
305 298
306 299 def hashrepofile(repo, file):
@@ -45,6 +45,7 b' class localstore(basestore.basestore):'
45 45 return lfutil.copyandhash(fd, tmpfile)
46 46 finally:
47 47 fd.close()
48 tmpfile.close()
48 49
49 50 def _verifyfile(self, cctx, cset, contents, standin, verified):
50 51 filename = lfutil.splitstandin(standin)
@@ -79,6 +79,7 b' class remotestore(basestore.basestore):'
79 79 tmpfile)
80 80 finally:
81 81 infile.close()
82 tmpfile.close()
82 83
83 84 def _verifyfile(self, cctx, cset, contents, standin, verified):
84 85 filename = lfutil.splitstandin(standin)
General Comments 0
You need to be logged in to leave comments. Login now