Commons IO
  1. Commons IO
  2. IO-209

FileSystemUtils.freeSpaceKb fails to return correct size for a windows mount point

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.4, 2.0, 3.x
    • Fix Version/s: 2.0
    • Component/s: Utilities
    • Labels:
      None
    • Environment:

      Windows XP, Vista, etc

      Description

      FileSystemUtils.freeSpaceKb fails to return correct result for a NTFS mount point or junction.

      Suppose I have a NTFS partition mounted at C:\Data\partition1.

      Now assume that the free space on Partition mounted as C: is 1GB and that mounted on "C:\Data\partition1" is 2GB. A call to FileSystemUtils.freeSpaceKb("C:\Data\partition1") will return the free space on C: and not on "C:\Data\partition1".

      This is because while running the "dir /-c" with the given path, the code just retains first 2 chars i.e. for any path under "C:\blah\de\blah", "dir /-c" will be called with "C:" which will return incorrect result.

      1. IO-209.patch
        1 kB
        Niall Pemberton

        Activity

        Aditya Kishore created issue -
        Hide
        Niall Pemberton added a comment -

        I wondering why that line was put in the first place with the comment "seems to make it work"

        It was added here, but no indication why:

        https://svn.apache.org/viewvc?diff_format=h&view=revision&revision=240439

        Show
        Niall Pemberton added a comment - I wondering why that line was put in the first place with the comment "seems to make it work" It was added here, but no indication why: https://svn.apache.org/viewvc?diff_format=h&view=revision&revision=240439
        Niall Pemberton made changes -
        Field Original Value New Value
        Attachment IO-209.patch [ 12451276 ]
        Hide
        Niall Pemberton added a comment -

        Looks to me like this was done because windows file names that contain things such as spaces cause the command to fail. Also I guess since whatever directory is passed windows gives the same free space result.

        Anyway I've removed that code that just takes the first two characters of the path and added quotes around the file name. This resolves the problems with file names and works on Windows 7 for me.

        http://svn.apache.org/viewvc?view=revision&revision=1002819

        Show
        Niall Pemberton added a comment - Looks to me like this was done because windows file names that contain things such as spaces cause the command to fail. Also I guess since whatever directory is passed windows gives the same free space result. Anyway I've removed that code that just takes the first two characters of the path and added quotes around the file name. This resolves the problems with file names and works on Windows 7 for me. http://svn.apache.org/viewvc?view=revision&revision=1002819
        Niall Pemberton made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Assignee Niall Pemberton [ niallp ]
        Fix Version/s 2.0 [ 12312961 ]
        Resolution Fixed [ 1 ]
        Mark Thomas made changes -
        Workflow jira [ 12471372 ] Default workflow, editable Closed status [ 12601887 ]
        Henri Yandell made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Resolved Resolved
        433d 8h 56m 1 Niall Pemberton 29/Sep/10 19:33
        Resolved Resolved Closed Closed
        406d 22h 35m 1 Henri Yandell 10/Nov/11 18:09

          People

          • Assignee:
            Niall Pemberton
            Reporter:
            Aditya Kishore
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 24h
              24h
              Remaining:
              Remaining Estimate - 24h
              24h
              Logged:
              Time Spent - Not Specified
              Not Specified

                Development