From 3e624306dea4de6f7a78a7bcf34a57882f731a2d Mon Sep 17 00:00:00 2001 From: Luca Milanesio Date: Wed, 10 Jan 2024 19:38:46 +0000 Subject: Allow to discover bitmap on disk created after the packfile When the bitmap file was created *after* a packfile had been loaded into the memory, JGit was unable to discover them. That happed because of two problems: 1. The PackDirectory.getPacks() does not implement the usual while loop that is scanning through the packs directory as in the other parts of JGit. 2. The scan packs does not look for newly created bitmap files if the packfile is already loaded in memory. Implement the normal packfiles scanning whenever the PackDirectory needs to return a list of packs, and make sure that any reused Pack object would have its associated bitmap properly refreshed from disk. Adapt the assertions in GcConcurrentTest with the rescanned list of Pack from the objects/packs directory. Bug: jgit-15 Change-Id: I2ed576cefd78a0e128b175228a59c9af51523d7b --- .../eclipse/jgit/internal/storage/file/GcConcurrentTest.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'org.eclipse.jgit.test') diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcConcurrentTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcConcurrentTest.java index 1519873b62..96a064989b 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcConcurrentTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcConcurrentTest.java @@ -186,13 +186,12 @@ public class GcConcurrentTest extends GcTestCase { // make sure gc() has caused creation of a new packfile assertNotEquals(oldPackName, newPackName); - // Even when asking again for the set of packfiles outdated data - // will be returned. As long as the repository can work on cached data - // it will do so and not detect that a new packfile exists. - assertNotEquals(getSinglePack(repository).getPackName(), newPackName); + // When asking again for the set of packfiles the new updated data + // will be returned because of the rescan of the pack directory. + assertEquals(getSinglePack(repository).getPackName(), newPackName); - // Only when accessing object content it is required to rescan the pack - // directory and the new packfile will be detected. + // When accessing object content the new packfile refreshed from + // the rescan triggered from the list of packs. repository.getObjectDatabase().open(b).getSize(); assertEquals(getSinglePack(repository).getPackName(), newPackName); assertNotNull(getSinglePack(repository).getBitmapIndex()); -- cgit v1.2.3