[jira] [Created] (VFS-354) RamFileProvider: moving dir with children fails to move children...

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

[jira] [Created] (VFS-354) RamFileProvider: moving dir with children fails to move children...

Sebb (Jira)
RamFileProvider: moving dir with children fails to move children...

                 Key: VFS-354
                 URL: https://issues.apache.org/jira/browse/VFS-354
             Project: Commons VFS
          Issue Type: Bug
    Affects Versions: 1.0
         Environment: N/A
            Reporter: Miroslav Pokorny

Below is a simple program which creates a vfs using a RamFileProvider. Note i have not verified if this works on other providers which are backed by a real filesystem. Im guessing moving on those will work because it would be a disaster for the hose os and it makes no sense that vfs does the moving of individual files.

Note refreshing the FileObject by fetching them again with resolveFile makes no difference, the "moved" directory remains empty but the file/dir are avaiable by using their absolute paths.

     * @param args
    public static void main(String[] args) throws Exception {

        DefaultFileSystemManager manager = new DefaultFileSystemManager();
        manager.addProvider("ram", new RamFileProvider());

        final FileObject from = manager.resolveFile("ram://from");

        final FileObject move = manager.resolveFile("ram://from/move");

        final FileObject fromMoveFile = manager.resolveFile("ram://from/move/file");

        final FileObject fromMoveSub = manager.resolveFile("ram://from/move/sub");

        final FileObject to = manager.resolveFile("ram://to");

        final FileObject moveAfter = manager.resolveFile("ram://to/move");
        System.out.println("target of move " + moveAfter + " exists + " + moveAfter.exists());

        System.out.println("move from " + move);
        System.out.println("\texists " + move.exists());
        try {
            System.out.println("\tchildren " + Arrays.toString(move.getChildren()));
        } catch (final Exception expected) {
            // ignore expected because folder was moved...
        System.out.println("move to " + moveAfter);
        System.out.println("\texists " + moveAfter.exists());
        System.out.println("\tchildren " + Arrays.toString(moveAfter.getChildren()));

        // these tests should print false because they were moved but it prints true...
        System.out.println("original file " + fromMoveFile + " exists " + fromMoveFile.exists());
        System.out.println("original sub dir " + fromMoveSub + " exists " + fromMoveSub.exists());

        // repeating tests with "refreshed" FileObjects problem remains.
        final FileObject fromMoveFileX = manager.resolveFile("ram://from/move/file");
        System.out.println("refreshed " + fromMoveFileX + " " + fromMoveFile.exists());

        final FileObject fromMoveSubX = manager.resolveFile("ram://from/move/sub");
        System.out.println("refreshed " + fromMoveSubX + " " + fromMoveSubX.exists());

        // file and dir should have moved but havent.
        final FileObject toMoveFile = manager.resolveFile("ram://to/move/file");
        System.out.println("target " + toMoveFile + " " + toMoveFile.exists());

        final FileObject toMoveSub = manager.resolveFile("ram://to/move/sub");
        System.out.println("target " + toMoveSub + " " + toMoveSub.exists());


target of move ram:///to/move exists + false
move from ram:///from/move
        exists false
move to ram:///to/move
        exists true
        children []
original file ram:///from/move/file exists true
original sub dir ram:///from/move/sub exists true
refreshed ram:///from/move/file true
refreshed ram:///from/move/sub true
target ram:///to/move/file false
target ram:///to/move/sub false

This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira