You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ace.apache.org by br...@apache.org on 2013/05/01 15:40:01 UTC
svn commit: r1477998 -
/ace/trunk/org.apache.ace.obr/src/org/apache/ace/obr/storage/file/BundleFileStore.java
Author: bramk
Date: Wed May 1 13:40:01 2013
New Revision: 1477998
URL: http://svn.apache.org/r1477998
Log:
ACE-346 Cleanup empty directories
Proactively remove directories left empty when a resource gets deleted to minimize the cost of lastmodied checks.
Modified:
ace/trunk/org.apache.ace.obr/src/org/apache/ace/obr/storage/file/BundleFileStore.java
Modified: ace/trunk/org.apache.ace.obr/src/org/apache/ace/obr/storage/file/BundleFileStore.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.obr/src/org/apache/ace/obr/storage/file/BundleFileStore.java?rev=1477998&r1=1477997&r2=1477998&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.obr/src/org/apache/ace/obr/storage/file/BundleFileStore.java (original)
+++ ace/trunk/org.apache.ace.obr/src/org/apache/ace/obr/storage/file/BundleFileStore.java Wed May 1 13:40:01 2013
@@ -120,16 +120,18 @@ public class BundleFileStore implements
public boolean remove(String fileName) throws IOException {
File file = createFile(fileName);
-
if (file.exists()) {
if (file.delete()) {
+ // deleting empty parent dirs
+ while ((file = file.getParentFile()) != null && !file.equals(m_dir) && file.list().length == 0) {
+ file.delete();
+ }
return true;
}
else {
throw new IOException("Unable to delete file (" + file.getAbsolutePath() + ")");
}
}
-
return false;
}