diff --git a/projects/vfs/src/python/vfs/impl.py b/projects/vfs/src/python/vfs/impl.py index 68cf3e9..6ad5656 100644 --- a/projects/vfs/src/python/vfs/impl.py +++ b/projects/vfs/src/python/vfs/impl.py @@ -32,11 +32,14 @@ class Vfs(object): if dest.is_symlink() and dest.readlink() == src: continue else: + _log.warn(f"Replacing {dest}") dest.unlink() + elif dest.is_dir(): + _log.warn(f"Replacing {dest}") + rmtree(dest) - assert not dest.exists() + assert not dest.exists(), f"{dest} should not exist" dest.symlink_to(src) - assert dest.exists() elif e[0] == "copy": raise NotImplementedError() @@ -47,6 +50,11 @@ class Vfs(object): elif e[0] == "mkdir": _, dest = e + if dest.is_dir(): + continue + elif dest.exists() or dest.is_symlink(): + dest.unlink() + dest.mkdir(exist_ok=True) elif e[0] == "unlink":