commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bojan Vukojevic (JIRA)" <>
Subject [jira] Created: (TRANSACTION-19) applyDeletes method does not delete dangling links
Date Fri, 15 Jun 2007 17:03:32 GMT
applyDeletes method does not delete dangling links

                 Key: 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

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
                    	//this is likely a dangling link                    	
                    // indicate, this has been done
                } else {
                    applyDeletes(removeFile, targetFile, rootDir);
                // delete empty target directories, except root dir
                if (!targetDir.equals(rootDir) && targetDir.list().length == 0) {

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:
For additional commands, e-mail:

View raw message