new functions

This commit is contained in:
Mateusz Gruszczyński
2026-05-05 08:21:36 +02:00
parent 0b580f590e
commit 3c14a6f510
3 changed files with 75 additions and 7 deletions

View File

@@ -26,9 +26,11 @@ class TorrentCache:
profile_id = int(profile["id"])
try:
rows = rtorrent.list_torrents(profile)
with self._lock:
old = dict(self._data.get(profile_id, {}))
post_check_changes = rtorrent.apply_post_check_policy(profile, rows, old)
fresh = {t["hash"]: t for t in rows}
with self._lock:
old = self._data.get(profile_id, {})
added = [v for h, v in fresh.items() if h not in old]
removed = [h for h in old.keys() if h not in fresh]
updated = []
@@ -45,7 +47,7 @@ class TorrentCache:
self._data[profile_id] = fresh
self._errors[profile_id] = ""
self._updated_at[profile_id] = time()
return {"ok": True, "profile_id": profile_id, "added": added, "updated": updated, "removed": removed}
return {"ok": True, "profile_id": profile_id, "added": added, "updated": updated, "removed": removed, "post_check_changes": post_check_changes}
except Exception as exc:
with self._lock:
self._errors[profile_id] = str(exc)