GC: prune all packfiles after the loosen phase

When loosening the objects inside the packfiles to be pruned, make sure
that the packfile list is stable and prune all the files after the
loosening is done.

This prevents a series of exceptions previously thrown when loosening
the packfiles, due to the too early pruning of the packfiles that were
still in the pack list.

Bug: 581532
Change-Id: I776776e2e083f1fa749d53f965bf50f919823b4f
This commit is contained in:
Luca Milanesio 2023-06-11 17:24:29 +01:00 committed by Matthias Sohn
parent dd92c1aa98
commit ac8d7838f0
1 changed files with 3 additions and 1 deletions

View File

@ -347,6 +347,7 @@ private void deleteOldPacks(Collection<Pack> oldPacks,
prunePreserved();
long packExpireDate = getPackExpireDate();
List<PackFile> packFilesToPrune = new ArrayList<>();
oldPackLoop: for (Pack oldPack : oldPacks) {
checkCancelled();
String oldName = oldPack.getPackName();
@ -364,9 +365,10 @@ private void deleteOldPacks(Collection<Pack> oldPacks,
loosen(inserter, reader, oldPack, ids);
}
oldPack.close();
prunePack(oldPack.getPackFile());
packFilesToPrune.add(oldPack.getPackFile());
}
}
packFilesToPrune.forEach(this::prunePack);
// close the complete object database. That's my only chance to force
// rescanning and to detect that certain pack files are now deleted.