dir!=files

This commit is contained in:
Daylin Morgan 2024-07-12 12:30:53 -05:00
parent 05d2146b97
commit 3ab39c45c1
Signed by: daylin
GPG key ID: 950D13E9719334AD

View file

@ -3417,20 +3417,24 @@ class Viv:
cli: Path, cli: Path,
yes: bool, yes: bool,
) -> None: ) -> None:
to_remove = [] to_remove_dirs = []
to_remove_files = []
if Cfg().cache_base.is_dir(): if Cfg().cache_base.is_dir():
to_remove.append(Cfg().cache_base) to_remove_dirs.append(Cfg().cache_base)
if src.is_file(): if src.is_file():
to_remove.append(src.parent if src == (Cfg().src) else src) to_remove_files.append(src.parent if src == (Cfg().src) else src)
if self.local_source and self.local_source.is_file(): if self.local_source and self.local_source.is_file():
if self.local_source.parent.name == "viv": if self.local_source.parent.name == "viv":
to_remove.append(self.local_source.parent) to_remove_files.append(self.local_source.parent)
else: else:
to_remove.append(self.local_source) to_remove_files.append(self.local_source)
if cli.is_file(): if cli.is_file():
to_remove.append(cli) to_remove_files.append(cli)
to_remove = to_remove_files + [
f for d in to_remove_dirs for f in d.glob("**/*")
]
to_remove = sorted(set(to_remove), key=lambda p: p.is_file()) to_remove = sorted(set(to_remove), key=lambda p: p.is_file())
if confirm( if confirm(
"Remove the above files/directories?", "Remove the above files/directories?",