aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test/tst/org/eclipse
diff options
context:
space:
mode:
authorHan-Wen Nienhuys <hanwen@google.com>2022-01-31 12:23:55 +0100
committerHan-Wen Nienhuys <hanwen@google.com>2022-02-02 14:12:15 +0100
commita650ae8ad3f459f02f5e362baef49316deed80bb (patch)
tree3027c61c27af3c62a4defdbfba00207fed6ba41a /org.eclipse.jgit.test/tst/org/eclipse
parent424c861477fbc48db38578d6f572c8d0cc2ba710 (diff)
downloadjgit-a650ae8ad3f459f02f5e362baef49316deed80bb.tar.gz
jgit-a650ae8ad3f459f02f5e362baef49316deed80bb.zip
reftable: tweaks for Windows
Reload the stack _before_ trying to delete the files. This ensures we don't trip over our own open file handles when deleting compacted tables. If there is another process reading the file, it may be impossible to delete the compacted tables. In this case, ignore the failure. For cleaning the garbage in this case, the protocol as described in https://www.git-scm.com/docs/reftable#_windows should be implemented. This is left for another commit. Bug: 578454 Change-Id: I7aa43508450041eb9376d9f67a0262ff7cc53c73
Diffstat (limited to 'org.eclipse.jgit.test/tst/org/eclipse')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileReftableStackTest.java6
1 files changed, 6 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileReftableStackTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileReftableStackTest.java
index 6c74f0079a..98e4b3e1b3 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileReftableStackTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileReftableStackTest.java
@@ -14,6 +14,7 @@ import static org.eclipse.jgit.lib.Ref.Storage.PACKED;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assume.assumeFalse;
import java.io.File;
import java.io.FileNotFoundException;
@@ -32,10 +33,12 @@ import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.ObjectIdRef;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.util.FileUtils;
+import org.eclipse.jgit.util.SystemReader;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+
public class FileReftableStackTest {
private static Ref newRef(String name, ObjectId id) {
@@ -118,6 +121,9 @@ public class FileReftableStackTest {
@SuppressWarnings({ "resource", "unused" })
@Test
public void missingReftable() throws Exception {
+ // Can't delete in-use files on Windows.
+ assumeFalse(SystemReader.getInstance().isWindows());
+
try (FileReftableStack stack = new FileReftableStack(
new File(reftableDir, "refs"), reftableDir, null,
() -> new Config())) {