Skip to content

MoreFiles.deleteRecursively fails spuriously if something else deletes some of the files while it's iterating #5697

Open

Description

We tried to switch from our own recursive deleter to Guava's MoreFiles.deleteRecursively and found many cases where it failed spuriously due to files not existing.

The use case is we have a thread that regularly retries deletions which previously failed, to properly clean up temp files. On some occasions the operating system will tell us that the deletion failed, but then seemingly delete the file in the future. (Yes, this is on Windows, I'm not sure how you guessed.)

A read-through of the Guava code reveals this:

I think if this were instead Files.deleteIfExists(Path) it would fail a lot less.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions