commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Niklas Gustavsson <nik...@protocol7.com>
Subject [transactions] Empty directories being deleted
Date Wed, 16 Nov 2005 21:05:09 GMT
Hi

when deleting a file, FileResourceManager will automatically delete any 
empty directories up to the store root on comiit. This would in many 
cases not be the expected behavior. Would it be okay to make this 
optional? The following test case shows the behavior:

     public void testDeleteOfEmptyDirs() throws Exception {
         File storeDir = new File("test-store");
         File subDir = new File(storeDir, "1/2/3");
         File workDir = new File("test-work");
         File testFile = new File(subDir, "foo.txt");

         subDir.mkdirs();
         workDir.mkdirs();

         testFile.createNewFile();

         FileResourceManager rm = new FileResourceManager(
                 storeDir.getPath(),
                 workDir.getPath(),
                 false, new Log4jLogger(Logger.getLogger("logger")));

         rm.start();
         String txId = rm.generatedUniqueTxId();
         rm.startTransaction(txId);

         rm.deleteResource(txId, "1/2/3/foo.txt");
         rm.commitTransaction(txId);

         assertFalse(testFile.exists());
         assertTrue(storeDir.exists());
         assertTrue(subDir.exists());
         assertTrue(workDir.exists());
     }

/niklas

-------
Niklas Gustavsson
http://www.protocol7.com
mailto:niklas@protocol7.com


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message