Rescan packs if a pack is modified in-place (part 1)
If a pack file is modified in place it usually means that some other
process has repacked this repository, but the contents of this one
pack remained the same, but the object offsets may be different due
to different pack creation settings. In such cases we can no longer
use the existing PacKFile or PackIndex instances and instead we need
to create new ones.
This isn't a full solution to the problem. It is possible for an
application to obtain a PackedObjectLoader, see the PackFile get
closed due to pressure on the WindowCache, then fail when the pack
is reopened due to the pack being recreated on disk. PackWriter
is very susceptible to this, as it caches PackedObjectLoaders for
a long time before it uses them to copy data out of an existing
pack file.
This particular solution only catches the failure where we had
opened the index a long time ago, closed the pack, and are now
opening it again in order to construct a PackedObjectLoader for
the caller.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>