Be better at removing dead links
This commit is contained in:
parent
3a8677c630
commit
1df60b873b
2 changed files with 8 additions and 2 deletions
|
@ -110,7 +110,7 @@ def build_fs(root: Path, dest: Path, prelude: List[str]) -> Vfs:
|
||||||
def load_state(statefile: Path) -> Vfs:
|
def load_state(statefile: Path) -> Vfs:
|
||||||
"""Load a persisted VFS state from disk. Sort of."""
|
"""Load a persisted VFS state from disk. Sort of."""
|
||||||
|
|
||||||
oldfs = Vfs()
|
oldfs = Vfs([])
|
||||||
|
|
||||||
if statefile.exists():
|
if statefile.exists():
|
||||||
log.debug("Loading statefile %s", statefile)
|
log.debug("Loading statefile %s", statefile)
|
||||||
|
@ -207,6 +207,8 @@ def do_apply(confdir, destdir, state_file, execute, optimize, require, exec_idem
|
||||||
root = confdir.resolve()
|
root = confdir.resolve()
|
||||||
dest = destdir.resolve()
|
dest = destdir.resolve()
|
||||||
|
|
||||||
|
log.info(f"Installing requirements {require}")
|
||||||
|
|
||||||
if not root.is_dir():
|
if not root.is_dir():
|
||||||
log.fatal(f"{confdir} does not exist!")
|
log.fatal(f"{confdir} does not exist!")
|
||||||
_exit(1)
|
_exit(1)
|
||||||
|
|
|
@ -51,10 +51,14 @@ class Vfs(object):
|
||||||
|
|
||||||
elif e[0] == "unlink":
|
elif e[0] == "unlink":
|
||||||
_, dest = e
|
_, dest = e
|
||||||
if dest.is_dir():
|
if dest.is_symlink():
|
||||||
|
dest.unlink()
|
||||||
|
elif dest.is_dir():
|
||||||
rmtree(dest)
|
rmtree(dest)
|
||||||
elif dest.is_file():
|
elif dest.is_file():
|
||||||
dest.unlink()
|
dest.unlink()
|
||||||
|
else:
|
||||||
|
raise Exception(f"Couldn't unlink {dest}")
|
||||||
|
|
||||||
def _append(self, msg):
|
def _append(self, msg):
|
||||||
self._log.append(msg)
|
self._log.append(msg)
|
||||||
|
|
Loading…
Reference in a new issue