X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=cmd%2Fbloom-cmd.py;h=9709239a612584f053def4528d8977107bde4ac7;hb=f841907461d0279faaddde750adf0b23d440a328;hp=8ee75869f9139d7068742bd4d0fa15823980b116;hpb=bda2a9e054b2a02780e38135d08c81246f010976;p=bup.git diff --git a/cmd/bloom-cmd.py b/cmd/bloom-cmd.py index 8ee7586..9709239 100755 --- a/cmd/bloom-cmd.py +++ b/cmd/bloom-cmd.py @@ -18,7 +18,7 @@ def do_bloom(path, outfilename): b = None if os.path.exists(outfilename): - b = git.ShaBloom(outfilename, readwrite=True) + b = git.ShaBloom(outfilename) if not b.valid(): debug1("bloom: Existing invalid bloom found, regenerating.\n") b = None @@ -42,17 +42,19 @@ def do_bloom(path, outfilename): log("bloom: Nothing to do\n") return - if b is not None: + if b: if len(b) != rest_count: log("bloom: size %d != idx total %d, regenerating\n" % (len(b), rest_count)) b = None - elif b.bits < git.MAX_BLOOM_BITS and \ - b.pfalse_positive(add_count) > git.MAX_PFALSE_POSITIVE: + elif (b.bits < git.MAX_BLOOM_BITS and + b.pfalse_positive(add_count) > git.MAX_PFALSE_POSITIVE): log("bloom: %d more entries => %.2f false positive, regenerating\n" % (add_count, b.pfalse_positive(add_count))) b = None - if b is None: # Need all idxs to build from scratch + else: + b = git.ShaBloom(outfilename, readwrite=True, expected=add_count) + if not b: # Need all idxs to build from scratch add += rest add_count += rest_count del rest @@ -65,8 +67,7 @@ def do_bloom(path, outfilename): if b is None: tfname = os.path.join(path, 'bup.tmp.bloom') tf = open(tfname, 'w+') - b = git.ShaBloom.create( - tfname, f=tf, readwrite=True, expected=add_count, k=opt.k) + b = git.ShaBloom.create(tfname, f=tf, expected=add_count, k=opt.k) count = 0 for name in add: ix = git.open_idx(name)