commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "sebastien DAVID (JIRA)" <j...@apache.org>
Subject [jira] Created: (VFS-206) moveTo on Folder does not update the FileName of children
Date Wed, 02 Apr 2008 13:09:26 GMT
moveTo on Folder does not update the FileName of children
---------------------------------------------------------

                 Key: VFS-206
                 URL: https://issues.apache.org/jira/browse/VFS-206
             Project: Commons VFS
          Issue Type: Bug
    Affects Versions: 1.0
         Environment: Windows
            Reporter: sebastien DAVID
            Priority: Critical


Hi,

I use the FTP provider.
When i move a folder, the destination folder is correctly created and the children are correctled
referenced by the destination folder.
But the FileName of the children and the cache are not updated and contains the old parent
path.
Ex:
Directory structure before the move:
/test/srcDir
/test/srcDir/File1
/test/srcDir/Dir1

Move to be applied:
/test/srcDir to /test/srcNewDir

Directory structure after the move:
/test/srcNewDir
/test/srcNewDir/File1
/test/srcNewDir/Dir1

I recreate the srcDir:  
FileObject srcDir = fs.resolveFile("/test/srcDir")
srcDir.createFolder();

I recreate the File1
FileObject file1 = fs.resolveFile("/test/srcDir/File1")

---> But here file1.exists()  return true !!!

With the following code, i fixed this problem:

I call this method after the doRename (in moveTo)

private void updateFileName(String p_NewParentPath) throws FileSystemException {
    Map cache = getFileSystem().getFileSystemManager().getFilesCache().getMap(getFileSystem());
    FileObject[] child = getChildren();
    for (int i=0 ; i<child.length ; ++i) {    
      // Remove from the cache the old FileName
      cache.remove(child[i].getName());
             
      // Update the FileName with the new  Parent
      child[i].getName().setPath(p_NewParentPath+FileName.SEPARATOR+child[i].getBaseName());
      
      // Put the new FileName in the Cache
      cache.put(child[i].getName(), child[i]);
      
      // Update the child if attached
      if (child[i].isAttached() && child[i].getType().hasChildren()) {
        child[i].updateFileName(child[i].getName().getPath());
      }
    }
  }

Note that the setPath is a new method on the FileName


Can you include this fix (or a better fix) in the next release ?
When the new release will be published ?

Thanks




-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message