Uploaded image for project: 'Commons IO'
  1. Commons IO
  2. IO-684

Add force version of PathUtils.delete() APIs and friends.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.7
    • 2.8.0
    • Utilities
    • None

    Description

      With the changes from IO-629 I'm getting an AccessDeniedException when trying to recursively delete a directory with read-only files, e.g. a .git repository. Before this change the directory was successfully deleted. It is due to the difference between File.delete() and Files.delete() (see https://stackoverflow.com/a/12234217/3375325).
      I think an option should be introduced to make the previous behavior available again with an overloaded method like PathUtils.delete(Path path, boolean force).

      Stacktrace:

      java.nio.file.AccessDeniedException: C:\Users\xyz\AppData\Local\Temp\.git\objects\pack\pack-6576964fbde069f1787513ce358d2260530d5738.idx
      	at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:83)
      	at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97)
      	at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102)
      	at sun.nio.fs.WindowsFileSystemProvider.implDelete(WindowsFileSystemProvider.java:269)
      	at sun.nio.fs.AbstractFileSystemProvider.deleteIfExists(AbstractFileSystemProvider.java:108)
      	at java.nio.file.Files.deleteIfExists(Files.java:1165)
      	at org.apache.commons.io.file.DeletingPathVisitor.visitFile(DeletingPathVisitor.java:99)
      	at org.apache.commons.io.file.DeletingPathVisitor.visitFile(DeletingPathVisitor.java:35)
      	at java.nio.file.Files.walkFileTree(Files.java:2670)
      	at java.nio.file.Files.walkFileTree(Files.java:2742)
      	at org.apache.commons.io.file.PathUtils.visitFileTree(PathUtils.java:535)
      	at org.apache.commons.io.file.PathUtils.deleteDirectory(PathUtils.java:265)
      	at org.apache.commons.io.file.PathUtils.delete(PathUtils.java:254)
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            jansohn Robin Jansohn
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: