Delete empty message cache directories

This commit is contained in:
AsamK 2017-06-15 23:47:00 +02:00
parent 4d3e67ff83
commit 24ab58cc14

View file

@ -1116,6 +1116,8 @@ class Manager implements Signal {
System.err.println("Failed to delete cached message file “" + fileEntry + "”: " + e.getMessage()); System.err.println("Failed to delete cached message file “" + fileEntry + "”: " + e.getMessage());
} }
} }
// Try to delete directory if empty
dir.delete();
} }
} }
@ -1169,6 +1171,8 @@ class Manager implements Signal {
try { try {
cacheFile = getMessageCacheFile(envelope.getSource(), now, envelope.getTimestamp()); cacheFile = getMessageCacheFile(envelope.getSource(), now, envelope.getTimestamp());
Files.delete(cacheFile.toPath()); Files.delete(cacheFile.toPath());
// Try to delete directory if empty
new File(getMessageCachePath()).delete();
} catch (IOException e) { } catch (IOException e) {
System.err.println("Failed to delete cached message file “" + cacheFile + "”: " + e.getMessage()); System.err.println("Failed to delete cached message file “" + cacheFile + "”: " + e.getMessage());
} }