[ 
https://issues.apache.org/jira/browse/IO-850?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Gary D. Gregory resolved IO-850.
--------------------------------
    Fix Version/s: 2.19.0
       Resolution: Fixed

> DeletingPathVisitor always fails to delete a dir when symbolic link target is 
> deleted before the link itself
> ------------------------------------------------------------------------------------------------------------
>
>                 Key: IO-850
>                 URL: https://issues.apache.org/jira/browse/IO-850
>             Project: Commons IO
>          Issue Type: Bug
>    Affects Versions: 2.15.1
>            Reporter: Johan Compagner
>            Priority: Major
>             Fix For: 2.19.0
>
>
> DeletingPathVisitor doesn't give us an option for the SimplePathVisitor 
> superclass visitFileFailedFunction property (that constructor also exposed to 
> the intermediate class CountingPathVisitor is not used/exposed in the 
> DeletingPathVisitor class)
> So i can't use that but the DeletingPathVisitor should use that, because i 
> can't delete a certain directory if you have something like this:
>  
> parentdir:
>   adir
>   symboliclinkpointingtoadir
>  
> if that happens and i call this Files.walkFileTree(path, 
> DeletingPathVisitor.withLongCounters());
> on the parent dir and it first deletes "adir" 
> then it will completely fail to delete that parentdir (or clean the parent 
> dir)
> this is because Files will try to open the directory stream of that 
> "symboliclinkpointingtoadir" and that will fail because the "adir" is already 
> gone. so its now an invalid symbolic link. The the Files walkFileTree 
> implementation does call visitFileFailed but that is competely not 
> implemented in the DeletingPathVisitor and i have no means of also adding it 
> to it.
> i think DeletingPathVisitor should just do what i now do in my own 
> implementation:
>  
>  
> {code:java}
>                                     public FileVisitResult 
> visitFileFailed(Path file, IOException exc) throws IOException
>                                     {
>                                         Files.deleteIfExists(file);
>                                         return FileVisitResult.CONTINUE;
>                                     }
>  
> {code}
> just try to delete that file and be done with it (this works fine)
> now it bombs out because that IOException is something like "FileNotFound" 
> and if if i call it again and again on that dir (so "adir" is already gone) 
> the DeletingPathVisitor is never able to delete/clean that parent dir it 
> always bombs out.
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to