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 (Issue Comment Edited) (JIRA)" <ji...@apache.org> on 2012/04/11 17:35:18 UTC

[jira] [Issue Comment Edited] (IO-319) FileUtils.sizeOfDirectory follows symbolic links.

    [ https://issues.apache.org/jira/browse/IO-319?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13251677#comment-13251677 ] 

Gary D. Gregory edited comment on IO-319 at 4/11/12 3:34 PM:
-------------------------------------------------------------

On Windows, the sym link is called an NTFS junction point. This has been available since Windows 2000 according to https://en.wikipedia.org/wiki/NTFS_symbolic_link

{noformat}
MKLINK [[/D] | [/H] | [/J]] Link Target

        /D      Creates a directory symbolic link.  Default is a file
                symbolic link.
        /H      Creates a hard link instead of a symbolic link.
        /J      Creates a Directory Junction.
        Link    specifies the new symbolic link name.
        Target  specifies the path (relative or absolute) that the new link
                refers to.
{noformat}

Can you inlude Windows support in your patch? I am on Windows myself.

Thank you!
                
      was (Author: garydgregory):
    On Windows, the sym link is called an NTFS junction point. This has been available since Windows 2000 according to https://en.wikipedia.org/wiki/NTFS_symbolic_link

MKLINK [[/D] | [/H] | [/J]] Link Target

        /D      Creates a directory symbolic link.  Default is a file
                symbolic link.
        /H      Creates a hard link instead of a symbolic link.
        /J      Creates a Directory Junction.
        Link    specifies the new symbolic link name.
        Target  specifies the path (relative or absolute) that the new link
                refers to.
                  
> FileUtils.sizeOfDirectory follows symbolic links.
> -------------------------------------------------
>
>                 Key: IO-319
>                 URL: https://issues.apache.org/jira/browse/IO-319
>             Project: Commons IO
>          Issue Type: Bug
>    Affects Versions: 2.1
>            Reporter: Ravi Prakash
>            Priority: Critical
>         Attachments: commons-io-319.patch
>
>
> First of all Thanks tons Apache Commons folks for all the amazing work! :) My first JIRA. Yayyy. I contributed B-)
> A symbolic link may create a cycle and so sizeOfDirectory crashes with an IllegalArgumentException. e.g. 
> {noformat}
> $ tree test
> test
> ├── file
> └── ravi
>     ├── cycle -> ../../test
>     └── file
> {noformat}
> causes FileUtils.sizeOfDirectory to crash like so
> {noformat}
> java TestJAVA
> Exception in thread "main" java.lang.IllegalArgumentException: <somepath>/test/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle does not exist
>         at org.apache.commons.io.FileUtils.sizeOf(FileUtils.java:2053)
>         at org.apache.commons.io.FileUtils.sizeOfDirectory(FileUtils.java:2089)
>         at org.apache.commons.io.FileUtils.sizeOf(FileUtils.java:2057)
>         at org.apache.commons.io.FileUtils.sizeOfDirectory(FileUtils.java:2089)
>         at org.apache.commons.io.FileUtils.sizeOf(FileUtils.java:2057)
>         at org.apache.commons.io.FileUtils.sizeOfDirectory(FileUtils.java:2089)
>         at org.apache.commons.io.FileUtils.sizeOf(FileUtils.java:2057)
>         at org.apache.commons.io.FileUtils.sizeOfDirectory(FileUtils.java:2089)
> {noformat}
> We faced the same issue in Hadoop :(. Checkout https://issues.apache.org/jira/browse/HADOOP-6963 for our solution

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