From 5d471ec3951f6850d568ec79fd1cce8b2131de13 Mon Sep 17 00:00:00 2001 From: Reid 'arrdem' McKenzie Date: Wed, 20 Oct 2021 23:54:17 -0600 Subject: [PATCH] exists() is the wrong predicate; false-negatives on broken links --- projects/vfs/src/python/vfs/impl.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/projects/vfs/src/python/vfs/impl.py b/projects/vfs/src/python/vfs/impl.py index 3f451f0..b405b75 100644 --- a/projects/vfs/src/python/vfs/impl.py +++ b/projects/vfs/src/python/vfs/impl.py @@ -28,12 +28,14 @@ class Vfs(object): elif e[0] == "link": _, src, dest = e - if dest.exists() and dest.is_symlink() and dest.readlink() == dest: - continue - else: - if dest.exists(): + if dest.is_file() or dest.is_symlink(): + if dest.is_symlink() and dest.readlink() == src: + continue + else: dest.unlink() - dest.symlink_to(src) + + assert not dest.exists() + dest.symlink_to(src) elif e[0] == "copy": raise NotImplementedError()