performance: reduce system calls required for remove_dead_links
`os.path.exists()` will report False if the target of a symlink doesn't exist, so we can avoid a costly call to realpath here.
This commit is contained in:
parent
79ddf6cf0d
commit
f013687397
@ -917,10 +917,8 @@ def remove_if_dead_link(path):
|
|||||||
Parameters:
|
Parameters:
|
||||||
path (str): The potential dead link
|
path (str): The potential dead link
|
||||||
"""
|
"""
|
||||||
if os.path.islink(path):
|
if os.path.islink(path) and not os.path.exists(path):
|
||||||
real_path = os.path.realpath(path)
|
os.unlink(path)
|
||||||
if not os.path.exists(real_path):
|
|
||||||
os.unlink(path)
|
|
||||||
|
|
||||||
|
|
||||||
def remove_linked_tree(path):
|
def remove_linked_tree(path):
|
||||||
|
Loading…
Reference in New Issue
Block a user