]> source.dussan.org Git - jgit.git/commitdiff
Use java.nio to delete path to get detailed errors 54/125754/4
authorLuca Milanesio <luca.milanesio@gmail.com>
Sat, 7 Jul 2018 22:09:36 +0000 (23:09 +0100)
committerMatthias Sohn <matthias.sohn@sap.com>
Wed, 25 Jul 2018 23:02:42 +0000 (01:02 +0200)
Get the full IOException of the reason why a directory
cannot be removed during GC.

Change-Id: Ia555bce009fa48087a73d677f1ce3b9c0b685b57
Signed-off-by: Luca Milanesio <luca.milanesio@gmail.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java

index 55d07512479f0e6c28d52103c3cd2b0b70422771..eb5c1db50ee252a41fd0d57acc7e1b5458390e93 100644 (file)
@@ -884,7 +884,7 @@ public class GC {
        }
 
        private void deleteEmptyRefsFolders() throws IOException {
-               Path refs = repo.getDirectory().toPath().resolve("refs"); //$NON-NLS-1$
+               Path refs = repo.getDirectory().toPath().resolve(Constants.R_REFS);
                try (Stream<Path> entries = Files.list(refs)) {
                        Iterator<Path> iterator = entries.iterator();
                        while (iterator.hasNext()) {
@@ -908,7 +908,7 @@ public class GC {
                return p.toFile().isDirectory();
        }
 
-       private boolean delete(Path d) {
+       private void delete(Path d) {
                try {
                        // Avoid deleting a folder that was just created so that concurrent
                        // operations trying to create a reference are not impacted
@@ -918,12 +918,12 @@ public class GC {
                                // If the folder is not empty, the delete operation will fail
                                // silently. This is a cheaper alternative to filtering the
                                // stream in the calling method.
-                               return d.toFile().delete();
+                               Files.delete(d);
                        }
                } catch (IOException e) {
-                       LOG.error(e.getMessage(), e);
+                       LOG.error(MessageFormat.format(JGitText.get().cannotDeleteFile, d),
+                                       e);
                }
-               return false;
        }
 
        /**