[
https://issues.apache.org/jira/browse/JCR-1394?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Jukka Zitting updated JCR-1394:
-------------------------------
Component/s: jackrabbit-core
Affects Version/s: (was: 1.4)
Fix Version/s: (was: 1.4)
> FileDataStore Garbage Collector and empty directories
> -----------------------------------------------------
>
> Key: JCR-1394
> URL: https://issues.apache.org/jira/browse/JCR-1394
> Project: Jackrabbit
> Issue Type: Improvement
> Components: jackrabbit-core
> Reporter: Jacco van Weert
> Priority: Minor
> Fix For: 1.5
>
> Original Estimate: 0.17h
> Remaining Estimate: 0.17h
>
> When the org.apache.jackrabbit.core.data.GarbageCollector is called for a
> FileDataStore the file objects are correctly deleted.
> But the (sub)directories aren't removed.
> In time this will result in a huge tree of unused empty directories
> I've created a small chance in method FileDataStore.deleteOlderRecursive()
> It will remove a directory when it hasn't any files entries. Please note that
> currently the file objects are stored three levels deep, so it
> will take three gc calls remove all directories. Which I think is no problem
> because the currently implementation is lightweighted.
> >>>>> CURRENT FileDataStore.java
> private int deleteOlderRecursive(File file, long min) {
> int count = 0;
> if (file.isFile() && file.exists() && file.canWrite()) {
> if (file.lastModified() < min) {
> DataIdentifier id = new DataIdentifier(file.getName());
> if (!inUse.containsKey(id)) {
> file.delete();
> count++;
> }
> }
> } else if (file.isDirectory()) {
> File[] list = file.listFiles();
> for (int i = 0; i < list.length; i++) {
> count += deleteOlderRecursive(list[i], min);
> }
> }
> return count;
> }
> >>>>>>> NEW
> private int deleteOlderRecursive(File file, long min) {
> int count = 0;
> if (file.isFile() && file.exists() && file.canWrite()) {
> if (file.lastModified() < min) {
> DataIdentifier id = new DataIdentifier(file.getName());
> if (!inUse.containsKey(id)) {
> file.delete();
> count++;
> }
> }
> } else if (file.isDirectory()) {
> File[] list = file.listFiles();
> if (list.length==0) {
> file.delete();
> } else {
> for (int i = 0; i < list.length; i++) {
> count += deleteOlderRecursive(list[i], min);
> }
> }
> }
> return count;
> }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.