Skip to content

Try to delete broken symlinks #17626

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

Closed

Conversation

IchHabRecht
Copy link
Contributor

If you delete the target of a symlink (at least on Windows systems) you
don't get the kind of the target anymore (obviously). Therefore it might
happen that a broken symlink to a directory should be removed with
unlink() which fails. This patch adds another check for a broken symlink
and tries to remove with rmdir() before throwing an exception. It helps
to clean up test folders on Windows systems (so already proofed by the
existing tests).

If you delete the target of a symlink (at least on Windows systems) you
don't get the kind of the target anymore (obviously). Therefore it might
happen that a broken symlink to a directory should be removed with
unlink() which fails. This patch adds another check for a broken symlink
and tries to remove with rmdir() before throwing an exception. It helps
to clean up test folders on Windows systems (so already proofed by the
existing tests).
@IchHabRecht IchHabRecht force-pushed the tryDeleteBrokenSymlink branch from 5069c74 to 58dd0b9 Compare January 31, 2016 13:49
@xabbuh
Copy link
Member

xabbuh commented Feb 3, 2016

Can you please add a test that would fail without this fix?

Status: Needs work

@fabpot
Copy link
Member

fabpot commented Feb 18, 2016

@IchHabRecht Can you add a unit test to cover the fix? Do you need help writing such a test?

@nicolas-grekas
Copy link
Member

Good catch, thanks @IchHabRecht.

nicolas-grekas added a commit that referenced this pull request Mar 2, 2016
This PR was submitted for the master branch but it was merged into the 2.3 branch instead (closes #17626).

Discussion
----------

Try to delete broken symlinks

If you delete the target of a symlink (at least on Windows systems) you
don't get the kind of the target anymore (obviously). Therefore it might
happen that a broken symlink to a directory should be removed with
unlink() which fails. This patch adds another check for a broken symlink
and tries to remove with rmdir() before throwing an exception. It helps
to clean up test folders on Windows systems (so already proofed by the
existing tests).

Commits
-------

8442ab1 [Filesystem] Try to delete broken symlinks
@fabpot fabpot closed this Mar 2, 2016
@stof
Copy link
Member

stof commented Mar 2, 2016

@nicolas-grekas have you added a test to prevent regression on this ?

@fabpot fabpot mentioned this pull request Mar 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants