Uploaded image for project: 'Commons VFS'
  1. Commons VFS
  2. VFS-311

When moving local file, target parent be left unaware of a new child

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 2.0
    • None
    • None

    Description

      When notifying target parent of a new child, AbstractFileObject.moveTo() calls getType() after movement was made. This call return FileType.IMAGINARY if file type was not explicitly cached before (the is the case for LocalFile-s which just update 'file' field), and handleCreate() will execute in vain.

      Possible fix is to cache fileType in advance:
      try
      {
      attach();

      // calculate the type BEFORE rename, since after source file moved getType() may return IMAGINARY
      FileType type = getType();

      doRename(destFile);

      // assuming file type won't change during rename
      (FileObjectUtils.getAbstractFileObject(destFile)).handleCreate(type);

      destFile.close(); // now the destFile is no longer imaginary. force reattach.

      handleDelete(); // fire delete-events. This file-object (src) is like deleted.
      }

      Attachments

        Activity

          People

            Unassigned Unassigned
            ksafonov Kirill Safonov
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: