diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2017-01-30 01:24:45 +0100 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2017-02-01 23:44:07 +0100 |
commit | 18cda3888c455e48de38088ee51803096a48ae28 (patch) | |
tree | 30510ef71649d4482fb1ccd7116744442c296151 /org.eclipse.jgit/src/org/eclipse/jgit | |
parent | a11bb03127b9ab193c956589381c496429f82d87 (diff) | |
download | jgit-18cda3888c455e48de38088ee51803096a48ae28.tar.gz jgit-18cda3888c455e48de38088ee51803096a48ae28.zip |
GC: delete empty directories after purging loose objects
In order to limit the number of directories we check for emptiness only
consider fanout directories which contained unreferenced loose objects
we deleted in the same gc run.
Change-Id: Idf8d512867ee1c8ed40bd55752122ce83a98ffa2
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java | 7 |
1 files changed, 7 insertions, 0 deletions
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 d1cdbeb46b..b608416868 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 @@ -475,12 +475,19 @@ public class GC { // loose objects. Make a last check, though, to avoid deleting objects // that could have been referenced while the candidates list was being // built (by an incoming push, for example). + Set<File> touchedFanout = new HashSet<>(); for (File f : deletionCandidates.values()) { if (f.lastModified() < expireDate) { f.delete(); + touchedFanout.add(f.getParentFile()); } } + for (File f : touchedFanout) { + FileUtils.delete(f, + FileUtils.EMPTY_DIRECTORIES_ONLY | FileUtils.IGNORE_ERRORS); + } + repo.getObjectDatabase().close(); } |