X-Git-Url: https://arthur.barton.de/gitweb/?p=bup.git;a=blobdiff_plain;f=lib%2Fbup%2Fcmd%2Flist_idx.py;h=99384cc9e39ccc738ba547592ec917b945518e28;hp=15e8b4c836ca3970dc1f9449eacb063607b82ba7;hb=13144702fca874fe40b08ef630f4b34ebaabc6a5;hpb=d2fa0418334507cb6ef08c0c9caca8e9bf5ce19d diff --git a/lib/bup/cmd/list_idx.py b/lib/bup/cmd/list_idx.py index 15e8b4c..99384cc 100755 --- a/lib/bup/cmd/list_idx.py +++ b/lib/bup/cmd/list_idx.py @@ -47,18 +47,20 @@ def main(argv): ix = git.open_idx(name) except git.GitError as e: add_error('%r: %s' % (name, e)) + ix.close() continue - if len(opt.find) == 40: - if ix.exists(bin): - out.write(b'%s %s\n' % (name, find)) - else: - # slow, exhaustive search - for _i in ix: - i = hexlify(_i) - if i.startswith(find): - out.write(b'%s %s\n' % (name, i)) - qprogress('Searching: %d\r' % count) - count += 1 + with ix: + if len(opt.find) == 40: + if ix.exists(bin): + out.write(b'%s %s\n' % (name, find)) + else: + # slow, exhaustive search + for _i in ix: + i = hexlify(_i) + if i.startswith(find): + out.write(b'%s %s\n' % (name, i)) + qprogress('Searching: %d\r' % count) + count += 1 if saved_errors: log('WARNING: %d errors encountered while saving.\n' % len(saved_errors))