mirror of
https://github.com/aclist/dztui.git
synced 2026-08-26 01:37:18 +02:00
feat: use concurrency for stale mods
This commit is contained in:
parent
85cbd2d183
commit
b14c63b23c
@ -24,6 +24,7 @@
|
||||
- Remember tree position in menus
|
||||
- Show hidden server count after filtering
|
||||
- Atomic map filters per server context
|
||||
- Use concurrency when checking stale mods (performance uplift)
|
||||
|
||||
## Changed
|
||||
- Reduce padding on keys button
|
||||
|
||||
@ -3,6 +3,8 @@ import hashlib
|
||||
import logging
|
||||
import shlex
|
||||
|
||||
from concurrent.futures import wait
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
|
||||
@ -145,26 +147,30 @@ def remove_stale_signatures(config: Path, versions: Path) -> None:
|
||||
for line in lines:
|
||||
f.write(line)
|
||||
|
||||
|
||||
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_path = Path(steam)
|
||||
|
||||
# TODO: use concurrency
|
||||
local = get_local_mod_ids(steam_path)
|
||||
servers = lookup(config, Preferences.IP_LIST)
|
||||
records = lookup(config, Preferences.IP_LIST)
|
||||
|
||||
all_mods = []
|
||||
for server in servers:
|
||||
split = server.split(":")
|
||||
ip = split[0]
|
||||
qport = split[2]
|
||||
remote_mods = []
|
||||
|
||||
mods = get_rules(ip, qport)
|
||||
all_mods += mods
|
||||
with ThreadPoolExecutor() as executor:
|
||||
futures = [
|
||||
executor.submit(push_record, record)
|
||||
for record in records
|
||||
]
|
||||
wait(futures)
|
||||
for future in futures:
|
||||
res = future.result()
|
||||
remote_mods += res
|
||||
|
||||
stale = []
|
||||
for mod in local:
|
||||
if mod not in all_mods:
|
||||
stale.append(mod)
|
||||
stale = [mod for mod in local if mod not in remote_mods]
|
||||
return stale
|
||||
|
||||
@ -596,6 +596,7 @@ class Controller(GObject.GObject):
|
||||
it = mod.iter
|
||||
path = model.get_path(it)
|
||||
# TODO: consider storing in ListStore as int
|
||||
# TODO: clone existing model and set outside of thread
|
||||
if int(mod[2]) in stale:
|
||||
model[path][4] = HEX_RED
|
||||
|
||||
@ -731,7 +732,7 @@ class Controller(GObject.GObject):
|
||||
func = self.get_callback()
|
||||
self.mediator.window.set_sensitive(True)
|
||||
# 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:
|
||||
args = self.get_callback_args()
|
||||
GLib.idle_add(func, *args)
|
||||
|
||||
@ -24,6 +24,7 @@
|
||||
- Remember tree position in menus
|
||||
- Show hidden server count after filtering
|
||||
- Atomic map filters per server context
|
||||
- Use concurrency when checking stale mods (performance uplift)
|
||||
|
||||
## Changed
|
||||
- Reduce padding on keys button
|
||||
|
||||
Loading…
Reference in New Issue
Block a user