Skip to content

Commit

Permalink
umu_util: hold a lock while removing rc4 files
Browse files Browse the repository at this point in the history
  • Loading branch information
R1kaB3rN committed Oct 12, 2024
1 parent af220cb commit 582b83b
Showing 1 changed file with 29 additions and 26 deletions.
55 changes: 29 additions & 26 deletions umu/umu_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from ssl import SSLContext, create_default_context
from subprocess import PIPE, STDOUT, Popen, TimeoutExpired

from filelock import FileLock
from Xlib import display

from umu.umu_consts import STEAM_COMPAT, UMU_LOCAL
Expand Down Expand Up @@ -184,32 +185,34 @@ def find_obsolete() -> None:
"sniper_platform_0.20231211.70175",
}
launcher: 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:
if file.is_file():
file.unlink()
if file.is_dir():
rmtree(str(file))

# $HOME/.local/share/Steam/compatibilitytool.d
launcher = STEAM_COMPAT.joinpath("ULWGL-Launcher")
if launcher.is_dir():
rmtree(str(launcher))

# $HOME/.cache
launcher = home.joinpath(".cache", "ULWGL")
if launcher.is_dir():
rmtree(str(launcher))

# $HOME/.local/share
launcher = home.joinpath(".local", "share", "ULWGL")
if launcher.is_dir():
rmtree(str(launcher))
lock: FileLock = FileLock(f"{UMU_LOCAL}/umu.lock")

with lock:
# 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:
if file.is_file():
file.unlink()
if file.is_dir():
rmtree(str(file))

# $HOME/.local/share/Steam/compatibilitytool.d
launcher = STEAM_COMPAT.joinpath("ULWGL-Launcher")
if launcher.is_dir():
rmtree(str(launcher))

# $HOME/.cache
launcher = home.joinpath(".cache", "ULWGL")
if launcher.is_dir():
rmtree(str(launcher))

# $HOME/.local/share
launcher = home.joinpath(".local", "share", "ULWGL")
if launcher.is_dir():
rmtree(str(launcher))


@contextmanager
Expand Down

0 comments on commit 582b83b

Please sign in to comment.