feat: version update logic

This commit is contained in:
aclist committed 2026-05-09 22:46:41 +09:00
1 parent 6e320763c9
commit 1268c388b0
4 files changed
+43 -8

No files matched your search

+27
View File
@@ -173,3 +173,30 @@ def get_mod_dir_size(path: Path) -> int:
elif i.is_dir(): elif i.is_dir():
size += get_mod_dir_size(i) size += get_mod_dir_size(i)
return size return size
def version_file_to_dict(file: Path) -> dict[str, str]:
versions = file.read_text().splitlines()
d: dict[str, str] = {}
for version in versions:
line = version.split(",")
mod = line[0]
stamp = line[1]
d[mod] = stamp
return d
def update_signatures(
mods: list[tuple[str, str, int, int]], version_file: Path
) -> None:
d = version_file_to_dict(version_file)
for _title, mod, stamp, size in mods:
d[mod] = str(stamp)
versions: list[str] = []
for k, v in d.items():
row = ",".join([k, v])
versions.append(row)
with open(version_file, "w") as f:
for version in versions:
f.write(f"{version}\n")
+1 -1
View File
@@ -25,7 +25,7 @@ def get_local_signatures(version_file: Path) -> dict[str, int]:
for line in lines: for line in lines:
line = line.split(",") line = line.split(",")
_id = line[0] _id = line[0]
_hash = line[1] _hash = int(line[1])
hashes[_id] = _hash hashes[_id] = _hash
return hashes return hashes
+14 -6
View File
@@ -18,7 +18,12 @@ from dzgui.api.steam import (
get_needs_update, get_needs_update,
) )
from dzgui.api.mods import get_mod_dir_size, get_local_mod_ids, get_local_mod_path from dzgui.api.mods import (
get_mod_dir_size,
get_local_mod_ids,
get_local_mod_path,
update_signatures,
)
from dzgui.const.constants import ( from dzgui.const.constants import (
APP_NAME, APP_NAME,
APPID_DAYZ, APPID_DAYZ,
@@ -236,7 +241,7 @@ class ConnectionManager:
dialog = ExceptionDialog(self.controller, server_timeout) dialog = ExceptionDialog(self.controller, server_timeout)
dialog.run() dialog.run()
def connect_steam(self) -> None: def _connect_steam(self) -> None:
print(self.record.ip) print(self.record.ip)
print(self.record.gameport) print(self.record.gameport)
print(self.appid) print(self.appid)
@@ -250,8 +255,9 @@ class ConnectionManager:
# TODO: add to history file and list store # TODO: add to history file and list store
@call_on_thread("Waiting for Steam to update mods") @call_on_thread("Waiting for Steam to update mods")
def update_mods(self, raise_window: bool) -> None: def _update_mods(self, raise_window: bool) -> None:
# NOTE: fast enqueue all mods in auto mode # NOTE: fast enqueue all mods in auto mode
prefs = self.controller.get_prefs()
for title, mod, stamp, size in self.missing_mods: for title, mod, stamp, size in self.missing_mods:
# TODO: boolean cancel button on threadman dialog sets event inside threadman # TODO: boolean cancel button on threadman dialog sets event inside threadman
# TODO: check for early cancel event via sigint # TODO: check for early cancel event via sigint
@@ -277,8 +283,10 @@ class ConnectionManager:
time.sleep(1) time.sleep(1)
# TODO: update version file # TODO: update version file
update_signatures(self.missing_mods, prefs.paths.version)
# TODO: get config path or just push steam path directly # TODO: get config path or just push steam path directly
rebuild_symlinks(self.controller.get_prefs().paths.config) rebuild_symlinks(prefs.paths.config)
# TODO: update tree checkmarks when finished # TODO: update tree checkmarks when finished
# TODO: make this internal to preconnect page # TODO: make this internal to preconnect page
func = StoredFunc(self.controller.update_status) func = StoredFunc(self.controller.update_status)
@@ -286,6 +294,6 @@ class ConnectionManager:
def update_and_connect(self, raise_window: bool) -> None: def update_and_connect(self, raise_window: bool) -> None:
if len(self.missing_mods) > 0: if len(self.missing_mods) > 0:
self.update_mods(raise_window) self._update_mods(raise_window)
else: else:
self.connect_steam() self._connect_steam()
+1 -1
View File
@@ -92,7 +92,7 @@ class ModManager:
if model is None: if model is None:
return None return None
tree_iter = model.get_iter(tree_path) tree_iter = model.get_iter(tree_path)
mod = model.get_value(tree_iter, 2)[0] mod = model.get_value(tree_iter, 2)
return mod, tree_iter return mod, tree_iter
def delete_single_mod(self, tree_path: Gtk.TreePath) -> Gtk.TreeIter | None: def delete_single_mod(self, tree_path: Gtk.TreePath) -> Gtk.TreeIter | None: