Merge branch 'stable-4.10' into stable-4.11
* stable-4.10: Fix GC to delete empty fanout directories after repacking Change-Id: I7118b9c668dcbb0f5435cc613e964c557bfebf01 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
commit
1a289e3420
|
@ -47,6 +47,7 @@
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
@ -113,8 +114,24 @@ public void testPackCommitsAndLooseOneWithPruneNow() throws Exception {
|
||||||
fsTick();
|
fsTick();
|
||||||
gc.gc();
|
gc.gc();
|
||||||
stats = gc.getStatistics();
|
stats = gc.getStatistics();
|
||||||
|
assertNoEmptyFanoutDirectories();
|
||||||
assertEquals(0, stats.numberOfLooseObjects);
|
assertEquals(0, stats.numberOfLooseObjects);
|
||||||
assertEquals(8, stats.numberOfPackedObjects);
|
assertEquals(8, stats.numberOfPackedObjects);
|
||||||
assertEquals(2, stats.numberOfPackFiles);
|
assertEquals(2, stats.numberOfPackFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void assertNoEmptyFanoutDirectories() {
|
||||||
|
File[] fanout = repo.getObjectsDirectory().listFiles();
|
||||||
|
for (File f : fanout) {
|
||||||
|
if (f.isDirectory()) {
|
||||||
|
String[] entries = f.list();
|
||||||
|
if (entries == null || entries.length == 0) {
|
||||||
|
assertFalse(
|
||||||
|
"Found empty fanout directory "
|
||||||
|
+ f.getAbsolutePath() + " after pruning",
|
||||||
|
f.getName().length() == 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -548,9 +548,12 @@ public void prune(Set<ObjectId> objectsToKeep) throws IOException,
|
||||||
pm.update(1);
|
pm.update(1);
|
||||||
if (d.length() != 2)
|
if (d.length() != 2)
|
||||||
continue;
|
continue;
|
||||||
File[] entries = new File(objects, d).listFiles();
|
File dir = new File(objects, d);
|
||||||
if (entries == null)
|
File[] entries = dir.listFiles();
|
||||||
|
if (entries == null || entries.length == 0) {
|
||||||
|
FileUtils.delete(dir, FileUtils.IGNORE_ERRORS);
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
for (File f : entries) {
|
for (File f : entries) {
|
||||||
checkCancelled();
|
checkCancelled();
|
||||||
String fName = f.getName();
|
String fName = f.getName();
|
||||||
|
|
Loading…
Reference in New Issue