[jira] Created: (VFS-206) moveTo on Folder does not update the FileName of children

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

[jira] Created: (VFS-206) moveTo on Folder does not update the FileName of children

ASF GitHub Bot (Jira)
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


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