summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorChristian Halstrick <christian.halstrick@sap.com>2013-03-15 11:08:17 +0100
committerChristian Halstrick <christian.halstrick@sap.com>2013-03-19 14:28:24 +0100
commitbd5e4eabc2a949dbce4d968d338106d46ff223df (patch)
treed006d568d9aef59219fd27d4706674f74493d320 /org.eclipse.jgit.test
parent67b98d5d40d3d531c2383bbc13d7d93abc7d1b8e (diff)
downloadjgit-bd5e4eabc2a949dbce4d968d338106d46ff223df.tar.gz
jgit-bd5e4eabc2a949dbce4d968d338106d46ff223df.zip
Fix GC for FileRepo in case packfile renames fail
Only on Windows the rename operation which renames temporary Packfiles (and index-files and bitmap-files) sometime fails. This happens only when renaming a temporary Packfile to a Packfile which already exists. Such situations occur if you run GC twice on a repo without modifying the repo inbetween. In such situations there was bug in GC which led to a corrupted repo whithout any packfiles anymore. This commit fixes the problem by introducing a utility method which renames a file and throws an IOException if it fails. This method also takes care to repeat a failing rename if our FS class has found out we are running on a platform with a unreliable File.renameTo() method. I am searching for a better solution because even with this utility method in hand a GC on a already GC'ed repo will fail on Windows. But at least with this fix we will not produce corrupted repos anymore. Bug: 389305 Change-Id: Iac1ab3e0b8c419c90404f2e2f3559672eb8f6d28 Signed-off-by: Christian Halstrick <christian.halstrick@sap.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GCTest.java7
1 files changed, 7 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GCTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GCTest.java
index bc60f64886..d5c8f12ef6 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GCTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GCTest.java
@@ -435,6 +435,13 @@ public class GCTest extends LocalDiskRepositoryTestCase {
assertEquals(0, stats.numberOfLooseObjects);
assertEquals(4, stats.numberOfPackedObjects);
assertEquals(1, stats.numberOfPackFiles);
+
+ // Do the gc again and check that it hasn't changed anything
+ gc.gc();
+ stats = gc.getStatistics();
+ assertEquals(0, stats.numberOfLooseObjects);
+ assertEquals(4, stats.numberOfPackedObjects);
+ assertEquals(1, stats.numberOfPackFiles);
}
@Test