From 0cfedb398a8ac2a4727d3f0b441e53a9b5258513 Mon Sep 17 00:00:00 2001 From: Reid 'arrdem' McKenzie Date: Thu, 28 Jul 2022 19:25:30 -0600 Subject: [PATCH] More cases of neading to clean during execution --- projects/vfs/src/python/vfs/impl.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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":