##// 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 def copyandhash(instream, outfile):
290 def copyandhash(instream, outfile):
291 '''Read bytes from instream (iterable) and write them to outfile,
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
292 computing the SHA-1 hash of the data along the way. Return the hash.'''
293 when done and return the hash.'''
294 hasher = util.sha1('')
293 hasher = util.sha1('')
295 for data in instream:
294 for data in instream:
296 hasher.update(data)
295 hasher.update(data)
297 outfile.write(data)
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 return hasher.hexdigest()
297 return hasher.hexdigest()
305
298
306 def hashrepofile(repo, file):
299 def hashrepofile(repo, file):
@@ -45,6 +45,7 b' class localstore(basestore.basestore):'
45 return lfutil.copyandhash(fd, tmpfile)
45 return lfutil.copyandhash(fd, tmpfile)
46 finally:
46 finally:
47 fd.close()
47 fd.close()
48 tmpfile.close()
48
49
49 def _verifyfile(self, cctx, cset, contents, standin, verified):
50 def _verifyfile(self, cctx, cset, contents, standin, verified):
50 filename = lfutil.splitstandin(standin)
51 filename = lfutil.splitstandin(standin)
@@ -79,6 +79,7 b' class remotestore(basestore.basestore):'
79 tmpfile)
79 tmpfile)
80 finally:
80 finally:
81 infile.close()
81 infile.close()
82 tmpfile.close()
82
83
83 def _verifyfile(self, cctx, cset, contents, standin, verified):
84 def _verifyfile(self, cctx, cset, contents, standin, verified):
84 filename = lfutil.splitstandin(standin)
85 filename = lfutil.splitstandin(standin)
General Comments 0
You need to be logged in to leave comments. Login now