Skip to content

removeDirectoryRecursive can throw an exception if a file vanishes before it removes it #60

Description

@joeyh
> removeDirectoryRecursive "/tmp/d"
Exception: /tmp/d/zzzzz: removeDirectoryRecursive: does not exist (No such file or directory)

Here /tmp/d/ contained a directory foo (with many subdirectories so it took some time to delete), and a subsequent file zzzzzz. Immediately after pressing enter in ghci, I launched a rm zzzzzz. So getDirectoryContents included the file, but it was gone by the time removeFile ran.

I feel that this is a surprising failure mode, and one that would be very easy to recover from, making uses of removeDirectoryRecursive more robust. If removeFile throws an exception due to the file no longer existing, removeDirectoryRecursive could continue with removing the rest of the directory and not propagate the exception.

(Testing rm -rf (on linux) in similar circumstances, I found that it skips over files that have already been deleted by something else, rather than failing.)

Metadata

Metadata

Assignees

Labels

type: (1) bugThe described behavior is not working as intended.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions