You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by oz...@apache.org on 2004/08/05 10:03:45 UTC
cvs commit: jakarta-commons-sandbox/transaction/src/java/org/apache/commons/transaction/file FileResourceManager.java
ozeigermann 2004/08/05 01:03:45
Modified: transaction/src/java/org/apache/commons/transaction/file
FileResourceManager.java
Log:
Empty directories not get deleted automatically
Revision Changes Path
1.6 +12 -14 jakarta-commons-sandbox/transaction/src/java/org/apache/commons/transaction/file/FileResourceManager.java
Index: FileResourceManager.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/transaction/src/java/org/apache/commons/transaction/file/FileResourceManager.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- FileResourceManager.java 26 Jul 2004 11:23:54 -0000 1.5
+++ FileResourceManager.java 5 Aug 2004 08:03:45 -0000 1.6
@@ -151,7 +151,7 @@
*
*/
- protected static void applyDeletes(File removeDir, File targetDir) throws IOException {
+ protected static void applyDeletes(File removeDir, File targetDir, File rootDir) throws IOException {
if (removeDir.isDirectory() && targetDir.isDirectory()) {
File[] files = removeDir.listFiles();
for (int i = 0; i < files.length; i++) {
@@ -164,20 +164,19 @@
// indicate, this has been done
removeFile.delete();
} else {
- applyDeletes(removeFile, targetFile);
+ applyDeletes(removeFile, targetFile, rootDir);
+ }
+ // delete empty target directories, except root dir
+ if (!targetDir.equals(rootDir) && targetDir.list().length == 0) {
+ targetDir.delete();
}
- // delete empty target directories
- // XXX do not do this as it may result in fatal delete of root dir
- // if (targetDir.list().length == 0) {
- // targetDir.delete();
- // }
}
}
}
/*
* --- object members ---
- *
+ *
*
*/
@@ -1290,7 +1289,6 @@
/**
* Inner class to hold the complete context, i.e. all information needed, for a transaction.
*
- * @author <a href="mailto:ozeigermann@c1-fse.de">Oliver Zeigermann</a>
*/
protected class TransactionContext {
@@ -1346,7 +1344,7 @@
closeResources();
upgradeLockToCommit();
try {
- applyDeletes(new File(deleteDir), new File(storeDir));
+ applyDeletes(new File(deleteDir), new File(storeDir), new File(storeDir));
FileHelper.moveRec(new File(changeDir), new File(storeDir));
} catch (IOException e) {
throw new ResourceManagerSystemException("Commit failed", ERR_SYSTEM, txId, e);
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org