From 8f8174649b8f00150c3f53a4d69809c0615f4560 Mon Sep 17 00:00:00 2001 From: R1kaB3rN <100738684+R1kaB3rN@users.noreply.github.com> Date: Wed, 9 Oct 2024 18:30:24 -0700 Subject: [PATCH] umu_util: delete obsolete files instead of warn --- umu/umu_util.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/umu/umu_util.py b/umu/umu_util.py index f3bc1c579..16e375aeb 100644 --- a/umu/umu_util.py +++ b/umu/umu_util.py @@ -6,7 +6,7 @@ from pathlib import Path from re import Pattern from re import compile as re_compile -from shutil import which +from shutil import rmtree, which from ssl import SSLContext, create_default_context from subprocess import PIPE, STDOUT, Popen, TimeoutExpired @@ -183,6 +183,7 @@ def find_obsolete() -> None: "umu_version.json", "sniper_platform_0.20231211.70175", } + obsolete: Path # Obsoleted files in $HOME/.local/share/umu from RC4 and below for file in UMU_LOCAL.glob("*"): @@ -190,19 +191,25 @@ def find_obsolete() -> None: file.name.startswith(("umu", "ulwgl")) ) if is_umu_file or file.name in obsoleted: - log.warning("'%s' is obsolete", file) + if file.is_file(): + file.unlink() + if file.is_dir(): + rmtree(str(file)) # $HOME/.local/share/Steam/compatibilitytool.d - if (launcher := STEAM_COMPAT.joinpath("ULWGL-Launcher")).is_dir(): - log.warning("'%s' is obsolete", launcher) + obsolete = STEAM_COMPAT.joinpath("ULWGL-Launcher") + if obsolete.is_dir(): + rmtree(str(obsolete)) # $HOME/.cache - if (cache := home.joinpath(".cache", "ULWGL")).is_dir(): - log.warning("'%s' is obsolete", cache) + obsolete = home.joinpath(".cache", "ULWGL") + if obsolete.is_dir(): + rmtree(str(obsolete)) # $HOME/.local/share - if (ulwgl := home.joinpath(".local", "share", "ULWGL")).is_dir(): - log.warning("'%s' is obsolete", ulwgl) + obsolete = home.joinpath(".local", "share", "ULWGL") + if obsolete.is_dir(): + rmtree(str(obsolete)) @contextmanager