]> arthur.barton.de Git - bup.git/commit
git/midx: provide context managers for idx classes
authorLuca Carlon <carlon.luca@gmail.com>
Thu, 21 May 2020 20:28:41 +0000 (22:28 +0200)
committerRob Browning <rlb@defaultvalue.org>
Sat, 23 May 2020 21:14:30 +0000 (16:14 -0500)
commite059fb80731c631d364f4c56e7202ed16e98ad84
treefcdf1d953fb58e7dad3daecebbb1ca8c2afd0a1b
parent0c009932e7eae09badf847b951025f2bad4c271f
git/midx: provide context managers for idx classes

Opening files and then mmap()ing them keeps the files open at the
filesystem level, and then they cannot be fully removed until the
fd is closed when giving up the mapping.

On most filesystems, the file still exists but is no longer visible
ion this case. However, at least on CIFS this results in the file
still being visible in the folder, but it can no longer be opened
again, or such. This leads to a crash in 'bup gc' because it wants
to re-evaluate the idx it just tried to delete.

Teach the PackIdx classes the context manager protocol so we can
easily unmap once they're no longer needed, and use that in bup gc
(for now only there).

For consistency, already add the context manager protocol also to
the midx, even if it's not strictly needed yet since bup gc won't
actually do this to an midx.

Signed-off-by: Luca Carlon <carlon.luca@gmail.com>
[add commit message based on error description, add midx part,
remove shatable to avoid live pointers into unmapped region]
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/gc.py
lib/bup/git.py
lib/bup/midx.py