Fix garbage collection failing to delete pack file

The loosen() method has opened pack file and the open pack file handle
may prevent it from being deleted e.g. on Windows. Fix this by closing
the pack file only after loosen() finished.

Bug: 574178
Change-Id: Icd59931a218d84c9c97b450eea87b21ed01248ff
Signed-off-by: andrew.xian2000@gmail.com
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
andrewxian2000 2021-06-15 09:58:52 +12:00
parent 2533a284c1
commit 64b0dee98f
1 changed files with 1 additions and 1 deletions

View File

@ -344,10 +344,10 @@ private void deleteOldPacks(Collection<Pack> oldPacks,
&& repo.getFS()
.lastModifiedInstant(oldPack.getPackFile())
.toEpochMilli() < packExpireDate) {
oldPack.close();
if (shouldLoosen) {
loosen(inserter, reader, oldPack, ids);
}
oldPack.close();
prunePack(oldPack.getPackFile());
}
}