From cff7c8d5e755fbf901282237e3d5ab60e3d1aed8 Mon Sep 17 00:00:00 2001 From: Reid 'arrdem' McKenzie Date: Thu, 28 Jul 2022 18:13:58 -0600 Subject: [PATCH] Deal with the node being a bad link --- projects/vfs/src/python/vfs/impl.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/projects/vfs/src/python/vfs/impl.py b/projects/vfs/src/python/vfs/impl.py index 2ac3fe7..68cf3e9 100644 --- a/projects/vfs/src/python/vfs/impl.py +++ b/projects/vfs/src/python/vfs/impl.py @@ -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}")