Skip to content

Commit

Permalink
umu_util: delete obsolete files instead of warn
Browse files Browse the repository at this point in the history
  • Loading branch information
R1kaB3rN committed Oct 10, 2024
1 parent dfb2410 commit 8f81746
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions umu/umu_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -183,26 +183,33 @@ 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("*"):
is_umu_file: bool = file.name.endswith(".py") and (
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
Expand Down

0 comments on commit 8f81746

Please sign in to comment.