Skip to content

fs.Dir.deleteTree: Fix DirNotEmpty condition #15402

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 23, 2023
Merged

Conversation

xEgoist
Copy link
Contributor

@xEgoist xEgoist commented Apr 22, 2023

deleteTree needs to retry once the directory is reported to be not empty. Otherwise, need_to_retry is always going to be false thus making the retry a dead code.

`deleteTree` needs to retry once the directory is reported to be not
empty. Otherwise, the retry condition is never reached.
Copy link
Member

@Vexu Vexu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be great to have a test for this.

@squeek502
Copy link
Collaborator

squeek502 commented Apr 22, 2023

Nice catch, looks like a straight-up typo from me in 063c5f4.

A test might be tricky to construct, as the relevant conditions would be something like:

  • Try to delete a tree
  • As a subdir is being iterated and its children deleted, a new file/dir is added to that subdir
  • It then tries to delete the subdir but gets DirNotEmpty
  • It now needs to retry to delete the contents of the subdir and then try to delete the subdir again

Before this PR, it would not actually ever do the 'retry' part. After this PR, it will.

@Vexu Vexu enabled auto-merge (rebase) April 22, 2023 23:24
@Vexu Vexu disabled auto-merge April 23, 2023 16:51
@Vexu Vexu merged commit ce3fe72 into ziglang:master Apr 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants