feat: complete transfer and eviction execution

This commit is contained in:
2026-07-23 09:14:40 +00:00
parent 884aed9921
commit b6de490b7e
17 changed files with 1445 additions and 81 deletions
+12
View File
@@ -10,6 +10,7 @@ from dataclasses import dataclass
from http.cookiejar import CookieJar
from pathlib import PurePosixPath
from typing import Any
from typing import Callable
from urllib import error, parse, request
from archive_clients.config import ServiceConfig
@@ -259,6 +260,8 @@ class QBittorrentReader:
*,
timeout: float,
poll_interval: float = 1,
cancel_check: Callable[[], None] | None = None,
progress_callback: Callable[[float], None] | None = None,
) -> RecheckResult:
selected = tuple(sorted(set(selected_file_indices)))
if not selected:
@@ -271,7 +274,9 @@ class QBittorrentReader:
"/api/v2/torrents/recheck", {"hashes": torrent_hash}
)
deadline = time.monotonic() + timeout
cancel_check = cancel_check or (lambda: None)
while True:
cancel_check()
record = self._torrent_record(torrent_hash)
state = record.get("state")
if not isinstance(state, str):
@@ -295,6 +300,13 @@ class QBittorrentReader:
item.get("index"): item.get("progress")
for item in files
}
if progress_callback is not None:
progress_callback(
sum(
max(0.0, min(float(progress.get(index, 0)), 1.0))
for index in selected
) / len(selected)
)
if all(
isinstance(progress.get(index), (int, float))
and float(progress[index]) >= 1