You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Stephen Haberman (JIRA)" <ji...@apache.org> on 2015/03/29 04:04:52 UTC
[jira] [Commented] (VFS-354) RamFileProvider: moving dir with
children fails to move children...
[ https://issues.apache.org/jira/browse/VFS-354?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14385605#comment-14385605 ]
Stephen Haberman commented on VFS-354:
--------------------------------------
Just confirmed the same thing is still happening using vfs 2.0.
> 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());
> manager.init();
> final FileObject from = manager.resolveFile("ram://from");
> from.createFolder();
> final FileObject move = manager.resolveFile("ram://from/move");
> move.createFolder();
> final FileObject fromMoveFile = manager.resolveFile("ram://from/move/file");
> fromMoveFile.createFile();
> final FileObject fromMoveSub = manager.resolveFile("ram://from/move/sub");
> fromMoveSub.createFolder();
> final FileObject to = manager.resolveFile("ram://to");
> to.createFolder();
> final FileObject moveAfter = manager.resolveFile("ram://to/move");
> System.out.println("target of move " + moveAfter + " exists + " + moveAfter.exists());
> move.moveTo(moveAfter);
> 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());
> }
> prints...
> 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 was sent by Atlassian JIRA
(v6.3.4#6332)