commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "sebastien DAVID (JIRA)" <>
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
             Project: Commons VFS
          Issue Type: Bug
    Affects Versions: 1.0
         Environment: Windows
            Reporter: sebastien DAVID
            Priority: Critical


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
Directory structure before the move:

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

Directory structure after the move:

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

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
      // Update the FileName with the new  Parent
      // 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()) {

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 ?


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

View raw message