feat: use concurrency for stale mods

This commit is contained in:
aclist committed 2026-02-13 20:41:09 +09:00
1 parent 85cbd2d183
commit b14c63b23c
4 files changed
+24 -15

No files matched your search

+1
View File
@@ -24,6 +24,7 @@
- Remember tree position in menus - Remember tree position in menus
- Show hidden server count after filtering - Show hidden server count after filtering
- Atomic map filters per server context - Atomic map filters per server context
- Use concurrency when checking stale mods (performance uplift)
## Changed ## Changed
- Reduce padding on keys button - Reduce padding on keys button
+20 -14
View File
@@ -3,6 +3,8 @@ import hashlib
import logging import logging
import shlex import shlex
from concurrent.futures import wait
from concurrent.futures import ThreadPoolExecutor
from dataclasses import dataclass from dataclasses import dataclass
from pathlib import Path from pathlib import Path
@@ -145,26 +147,30 @@ def remove_stale_signatures(config: Path, versions: Path) -> None:
for line in lines: for line in lines:
f.write(line) f.write(line)
def find_stale_mods(config: Path) -> list[int]: def find_stale_mods(config: Path) -> list[int]:
def push_record(rec: str) -> list:
add = rec.split(":")
ip = add[0]
qport = add[2]
return get_rules(ip, qport)
steam = lookup(config, Preferences.DEFAULT) steam = lookup(config, Preferences.DEFAULT)
steam_path = Path(steam) steam_path = Path(steam)
# TODO: use concurrency
local = get_local_mod_ids(steam_path) local = get_local_mod_ids(steam_path)
servers = lookup(config, Preferences.IP_LIST) records = lookup(config, Preferences.IP_LIST)
all_mods = [] remote_mods = []
for server in servers:
split = server.split(":")
ip = split[0]
qport = split[2]
mods = get_rules(ip, qport) with ThreadPoolExecutor() as executor:
all_mods += mods futures = [
executor.submit(push_record, record)
for record in records
]
wait(futures)
for future in futures:
res = future.result()
remote_mods += res
stale = [] stale = [mod for mod in local if mod not in remote_mods]
for mod in local:
if mod not in all_mods:
stale.append(mod)
return stale return stale
+2 -1
View File
@@ -596,6 +596,7 @@ class Controller(GObject.GObject):
it = mod.iter it = mod.iter
path = model.get_path(it) path = model.get_path(it)
# TODO: consider storing in ListStore as int # TODO: consider storing in ListStore as int
# TODO: clone existing model and set outside of thread
if int(mod[2]) in stale: if int(mod[2]) in stale:
model[path][4] = HEX_RED model[path][4] = HEX_RED
@@ -731,7 +732,7 @@ class Controller(GObject.GObject):
func = self.get_callback() func = self.get_callback()
self.mediator.window.set_sensitive(True) self.mediator.window.set_sensitive(True)
# TODO: spawn error dialog if API crawl failed # TODO: spawn error dialog if API crawl failed
# most likely going to drop this # most likely going to drop callback method
if func is not None: if func is not None:
args = self.get_callback_args() args = self.get_callback_args()
GLib.idle_add(func, *args) GLib.idle_add(func, *args)
+1
View File
@@ -24,6 +24,7 @@
- Remember tree position in menus - Remember tree position in menus
- Show hidden server count after filtering - Show hidden server count after filtering
- Atomic map filters per server context - Atomic map filters per server context
- Use concurrency when checking stale mods (performance uplift)
## Changed ## Changed
- Reduce padding on keys button - Reduce padding on keys button