]> arthur.barton.de Git - bup.git/commitdiff
cmd/bloom: use mkstemp() instead of NamedTemporaryFile().
authorAvery Pennarun <apenwarr@gmail.com>
Mon, 7 Feb 2011 08:55:10 +0000 (00:55 -0800)
committerAvery Pennarun <apenwarr@gmail.com>
Mon, 7 Feb 2011 09:31:49 +0000 (01:31 -0800)
Older versions of python (I tested python 2.5) don't support the
delete=False parameter to NamedTemporaryFile().  In any case, it's not
actually a temporary file since we're not planning to delete it.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
cmd/bloom-cmd.py

index 44579ac462fed276ce7b939246e63083a90d9393..434be3204d8fc3f85ec70ced3514499f1acddf82 100755 (executable)
@@ -62,10 +62,10 @@ def do_bloom(path, outfilename):
 
     tempname = None
     if b is None:
-        tf = tempfile.NamedTemporaryFile(
-                dir=path, suffix='bup.bloom', delete=False)
+        tfd,tfname = tempfile.mkstemp(dir=path, suffix='bup.bloom')
+        tf = os.fdopen(tfd, 'w+')
         b = git.ShaBloom.create(
-                tf.name, f=tf, readwrite=True, expected=add_count, k=opt.k)
+                tfname, f=tf, readwrite=True, expected=add_count, k=opt.k)
     count = 0
     for ix in add:
         progress('Writing bloom: %d/%d\r' % (count, len(add)))