[transactions] Empty directories being deleted

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[transactions] Empty directories being deleted

Niklas Gustavsson
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:[hidden email]


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [transactions] Empty directories being deleted

Oliver Zeigermann
Well, as you are - by contract with the FileResourceManager - not
allowed to access the folder manager by it directly your test case is
invalid as well. In other words, if you follow the contract you will
never see any directories at all.

Oliver

2005/11/16, Niklas Gustavsson <[hidden email]>:

> 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:[hidden email]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]