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 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]