You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gary D. Gregory (Closed) (JIRA)" <ji...@apache.org> on 2012/03/29 23:29:29 UTC
[jira] [Closed] (IO-300) FileUtils.moveDirectoryToDirectory removes
source directory if destination is a subdirectory
[ https://issues.apache.org/jira/browse/IO-300?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Gary D. Gregory closed IO-300.
------------------------------
Version 2.2 has been released and addresses this issue.
> FileUtils.moveDirectoryToDirectory removes source directory if destination is a subdirectory
> --------------------------------------------------------------------------------------------
>
> Key: IO-300
> URL: https://issues.apache.org/jira/browse/IO-300
> Project: Commons IO
> Issue Type: Bug
> Reporter: dennis lucero
> Fix For: 2.2
>
> Attachments: IO-300.patch
>
>
> Since moveDirectoryToDirectory performs a copy then delete, if you specify a target directory that is a subdirectory of the source, everything under the source directory is deleted.
> Steps to recreate:
> File dest = new File("/tmp/dir1/dir2");
> File src = new File("/tmp/dir1/");
> dest.mkdirs();
> System.out.println(src.exists());
> FileUtils.moveDirectoryToDirectory(src, dest, false);
> System.out.println(src.exists());
> Output:
> true
> false
> If you try the same thing with a move command on Linux, you receive: "mv: cannot move `dir1/' to a subdirectory of itself, `dir1/dir2/dir1'"
> Maybe throw an exception if dest.getCanonicalPath().startsWith(src.getCanonicalPath())
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira