]> source.dussan.org Git - jgit.git/commitdiff
GC: prune all packfiles after the loosen phase 10/202510/2
authorLuca Milanesio <luca.milanesio@gmail.com>
Sun, 11 Jun 2023 16:24:29 +0000 (17:24 +0100)
committerMatthias Sohn <matthias.sohn@sap.com>
Wed, 5 Jul 2023 13:28:16 +0000 (15:28 +0200)
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

org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java

index 4fc9582d333f45f179dd9333b4908b77e2a3b9c2..4bb7c8f3d39112712c2c4829edff5bc80b722d0b 100644 (file)
@@ -347,6 +347,7 @@ public class GC {
 
                prunePreserved();
                long packExpireDate = getPackExpireDate();
+               List<PackFile> packFilesToPrune = new ArrayList<>();
                oldPackLoop: for (Pack oldPack : oldPacks) {
                        checkCancelled();
                        String oldName = oldPack.getPackName();
@@ -364,9 +365,10 @@ public class GC {
                                        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.