[
https://issues.apache.org/jira/browse/TRANSACTION-19?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12505371
]
Oliver Zeigermann commented on TRANSACTION-19:
----------------------------------------------
I can quite follow you here, though I am sure there is substance to what you
have. Could you give an example scenario to explain? Thanks in advance!
> applyDeletes method does not delete dangling links
> --------------------------------------------------
>
> Key: TRANSACTION-19
> URL: https://issues.apache.org/jira/browse/TRANSACTION-19
> Project: Commons Transaction
> Issue Type: Bug
> Affects Versions: 1.2
> Environment: Linux CentOS, Java 1.5
> Reporter: Bojan Vukojevic
> Assignee: Oliver Zeigermann
>
> applyDeletes method will not delete any dangling links. Even if the link was
> valid, code may run into this situation if the file is passed to be deleted
> before link is registered for deletion. Code will delete the file
> effectivelly creating a dangling link that will not be deleted.
> The fix might be another change to applyDeletes method i.e. something like:
> 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++) {
> File removeFile = files[i];
> File targetFile = new File(targetDir, removeFile.getName());
> if (!removeFile.isDirectory()) {
> if (targetFile.exists()) {
> if (!targetFile.delete()) {
> throw new IOException("Could not delete file " +
> removeFile.getName()
> + " in directory targetDir");
> }
> } else if(!targetFile.isFile()){ //============ CHANGE
> to delete dangling link=============
> //this is likely a dangling link
> targetFile.delete();
> }
> // indicate, this has been done
> removeFile.delete();
> } else {
> applyDeletes(removeFile, targetFile, rootDir);
> }
> // delete empty target directories, except root dir
> if (!targetDir.equals(rootDir) && targetDir.list().length ==
> 0) {
> targetDir.delete();
> }
> }
> }
> }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]