# SYNOPSIS
-bup bloom [-d dir] [-o outfile] [-k hashes] [-c idxfile]
+bup bloom [-d dir] [-o outfile] [-k hashes] [-c idxfile] [-f] [--ruin]
# DESCRIPTION
# OPTIONS
+--ruin
+: destroy bloom filters by setting the whole bitmask to
+ zeros. you really want to know what you are doing if
+ run this and you want to delete the resulting bloom
+ when you are done with it.
+
-f, --force
: don't update the existing bloom file; generate a new
one from scratch.
optspec = """
bup bloom [options...]
--
+ruin ruin the specified bloom file (clearing the bitfield)
f,force ignore existing bloom file and regenerate it from scratch
o,output= output bloom filename (default: auto)
d,dir= input directory to look for idx files (default: auto)
c,check= check the given .idx file against the bloom filter
"""
+
+def ruin_bloom(bloomfilename):
+ rbloomfilename = git.repo_rel(bloomfilename)
+ if not os.path.exists(bloomfilename):
+ log("%s\n" % bloomfilename)
+ add_error("bloom: %s not found to ruin\n" % rbloomfilename)
+ return
+ b = bloom.ShaBloom(bloomfilename, readwrite=True, expected=1)
+ b.map[16:16+2**b.bits] = '\0' * 2**b.bits
+
+
def check_bloom(path, bloomfilename, idx):
rbloomfilename = git.repo_rel(bloomfilename)
ridx = git.repo_rel(idx)
outfilename = opt.output or os.path.join(path, 'bup.bloom')
if opt.check:
check_bloom(path, outfilename, opt.check)
+ elif opt.ruin:
+ ruin_bloom(outfilename)
else:
do_bloom(path, outfilename)