From 8ab89ef066f91a7d39b705f4e61498f37291ffab Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Mon, 27 Aug 2018 01:13:38 +0200 Subject: [PATCH 1/2] Fix NoSuchFileException during directory cleanup in RefDirectory Bug: 538285 Change-Id: Iab5c381a412cb2c2176af55189668c267ed29fbc Signed-off-by: Matthias Sohn --- .../org/eclipse/jgit/internal/storage/file/RefDirectory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java index b088d7266..450f3939a 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java @@ -1287,7 +1287,7 @@ private static void delete(File file, int depth, LockFile rLck) File dir = file.getParentFile(); for (int i = 0; i < depth; ++i) { try { - Files.delete(dir.toPath()); + Files.deleteIfExists(dir.toPath()); } catch (DirectoryNotEmptyException e) { // Don't log; normal case when there are other refs with the // same prefix From ddf56d6f85b6d33aba186d1c279b33cc311585c4 Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Mon, 27 Aug 2018 01:20:31 +0200 Subject: [PATCH 2/2] Fix NoSuchFileException in GC.deleteTempPacksIdx() This exception is thrown in GC.deleteTempPacksIdx() if the repository has no packs. Bug: 538286 Change-Id: Ieb482be751226baf0843068a0f847e0cdc6e0cb6 Signed-off-by: Matthias Sohn --- .../src/org/eclipse/jgit/internal/storage/file/GC.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java index 3fab484f2..de1b8c1f8 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java @@ -996,6 +996,9 @@ private void deleteOrphans() { private void deleteTempPacksIdx() { Path packDir = repo.getObjectDatabase().getPackDirectory().toPath(); Instant threshold = Instant.now().minus(1, ChronoUnit.DAYS); + if (!Files.exists(packDir)) { + return; + } try (DirectoryStream stream = Files.newDirectoryStream(packDir, "gc_*_tmp")) { //$NON-NLS-1$ stream.forEach(t -> {