Compare commits

..

6 Commits

Author SHA1 Message Date
aclist
33c4f6e526
Merge 6a3b4b2bfb into e92df8c062 2026-07-08 01:58:46 +00:00
aclist
6a3b4b2bfb fix: cast result to str
Some checks are pending
Mirror to Codeberg / mirror-to-codeberg (push) Waiting to run
2026-07-08 10:58:40 +09:00
aclist
8652259053 feat: convert appid to name 2026-07-08 10:58:12 +09:00
aclist
e92df8c062
Merge pull request #398 from u-alexandru/fix/history-file-not-found
Some checks failed
Mirror to Codeberg / mirror-to-codeberg (push) Has been cancelled
fix: prevent stuck launch dialog when history file is missing
2026-07-08 10:41:36 +09:00
aclist
eff31e2bd3 chore: clear typehinting errors 2026-07-08 10:07:16 +09:00
u-alexandru
494311e8df fix: prevent stuck launch dialog when history file is missing
update_history_file() opened dzg.history in read mode without handling a
missing file. dzg.history is only created the first time it is written, so
on a fresh install the very first server connection raised FileNotFoundError
inside the post-launch cleanup callback:

  _destroy_on_idle -> _add_to_history_and_return -> update_history_file

The exception propagated out of the GLib idle callback before destroy_dialog()
ran, orphaning the "Waiting for DayZ to launch" modal so it could never be
closed from the UI and its Cancel button was unresponsive.

Treat a missing history file as an empty history so the first connection
records history normally instead of crashing the cleanup callback.
2026-07-07 18:45:22 +03:00
6 changed files with 32 additions and 19 deletions

View File

@ -1,4 +1,3 @@
import json
import struct
from dataclasses import dataclass
@ -404,7 +403,6 @@ def get_pefile_path(steam_path: Path, appid: int) -> Path:
return pe_path
def get_pretty_version(steam_path: Path, appid: int) -> str | None:
try:
pe_file_path = get_pefile_path(steam_path, appid)

View File

@ -1,12 +1,10 @@
import json
import logging
import os
import psutil
import requests
import subprocess
import vdf
import vdf # type: ignore
from shlex import shlex
from pathlib import Path
from typing import Any, Union
from warnings import deprecated
@ -25,9 +23,15 @@ from dzgui.const.constants import (
REQUEST_TIMEOUT,
VDF_PATH,
)
from dzgui.const.endpoints import SUB_ENDPOINT, STEAM_PUBLISHED_FILES, UNSUB_ENDPOINT
from dzgui.const.endpoints import (
APP_DETAILS,
SUB_ENDPOINT,
STEAM_PUBLISHED_FILES,
UNSUB_ENDPOINT,
)
from dzgui.strings import wizard
from dzgui.util.bash import concat_bash_args
from dzgui.util.strings import unknown
logger = logging.getLogger(APP_NAME)
@ -260,7 +264,7 @@ def enqueue_mod(client: str, mod: str, appid: int) -> None:
@deprecated("Cf. https://github.com/ValveSoftware/steam-for-linux/issues/9672")
def get_registry() -> dict[str, Any] | None:
def get_registry() -> Any | None:
home = os.getenv("HOME")
try:
with open(f"{home}/.steam/registry.vdf") as f:
@ -294,9 +298,9 @@ def _get_running_app() -> int | None:
if registry is None:
return None
try:
return registry["Registry"]["HKCU"]["Software"]["Valve"]["Steam"][
"RunningAppID"
]
return int(
registry["Registry"]["HKCU"]["Software"]["Valve"]["Steam"]["RunningAppID"]
)
except Exception:
return None
@ -319,7 +323,7 @@ def get_running_app() -> int | None:
args = proc.cmdline()
appid = (row for row in args if FLAG in row)
try:
return str(next(appid).split("=")[1])
return int(next(appid).split("=")[1])
except StopIteration:
return None
return None
@ -393,3 +397,15 @@ def get_app_path(folders_path: Path, appid: int) -> Path:
)
return Path(app_path)
def get_app_name(appid: int) -> str:
payload = {"appids": [appid]}
res = requests.get(APP_DETAILS, params=payload)
if res.status_code != 200:
return unknown
try:
return str(res.json()[str(appid)]["data"]["name"])
except Exception as e:
logger.debug(e)
return unknown

View File

@ -5,6 +5,7 @@ STEAM_PUBLISHED_FILES = (
STEAM_SERVERS = "https://api.steampowered.com/IGameServersService/GetServerList/v1"
SUB_ENDPOINT = "https://api.steampowered.com/IPublishedFileService/Subscribe/v1"
UNSUB_ENDPOINT = "https://api.steampowered.com/IPublishedFileService/Unsubscribe/v1"
APP_DETAILS = "https://store.steampowered.com/api/appdetails?"
BM_SERVERS = "https://api.battlemetrics.com/servers?"
GITHUB = "https://github.com/aclist"

View File

@ -3,11 +3,8 @@ import subprocess
import shutil
import logging
from warnings import deprecated
from dzgui.const.constants import (
APP_NAME,
DAYZ_BINARY,
STEAM_CMD,
FLATPAK_APPID,
FLATPAK_CMD,
@ -15,8 +12,6 @@ from dzgui.const.constants import (
FLATPAK_SANDBOX,
)
from dzgui.util.format import format_exception
logger = logging.getLogger(APP_NAME)

View File

@ -55,8 +55,11 @@ class ConfigManager:
self.update_config(Preferences.IP_LIST, ips)
def update_history_file(self, fqip: str) -> None:
try:
with open(self.prefs.paths.history, "r") as f:
ips = [line.rstrip() for line in f.readlines()]
except FileNotFoundError:
ips = []
seen = set()
ips.append(fqip)

View File

@ -141,7 +141,7 @@ class ModManager:
app_path_exp = PeFile.get_nested_app_path(steam_path, APPID_DAYZ_EXP)
symlink = app_path_exp / md5
symlink.unlink()
except PeFile.AppNotInstalledError:
except Exception:
pass
time.sleep(API_RATE_LIMIT)