Deal with the node being a bad link

This commit is contained in:
Reid 'arrdem' McKenzie 2022-07-28 18:13:58 -06:00
parent 31a0019546
commit bbb4f83071

View file

@ -51,12 +51,16 @@ class Vfs(object):
elif e[0] == "unlink":
_, dest = e
if dest.is_symlink():
# Note that a path which is a dangling symlink will NOT exist but WILL be a symlink
if not dest.exists() and not dest.is_symlink():
return
# Files and dirs just unlink
if dest.is_symlink() or dest.is_file():
dest.unlink()
# Dirs require recursion
elif dest.is_dir():
rmtree(dest)
elif dest.is_file():
dest.unlink()
# Don't succeed silently
else:
raise Exception(f"Couldn't unlink {dest}")