Implement per-file import for in-progress torrents

Files within a downloading torrent are now imported as soon as their
individual progress reaches 100%, without waiting for the full torrent
to complete. A new processed_files table (info_hash, file_name) tracks
which files have been handled to avoid redundant re-hashing each poll.

- db.py: add processed_files table, is_file_processed, record_processed_file
- qbit_client.py: replace get_completed_torrents with get_torrents(filter, category)
- stash_handler.py: extract process_torrent_files helper, daemon now polls
  both downloading and completed torrents each cycle

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-18 21:51:52 -05:00
parent 6adfd77236
commit 5bcb35e737
4 changed files with 134 additions and 42 deletions
+5 -3
View File
@@ -37,9 +37,11 @@ class QBitClient:
resp.raise_for_status()
return resp
def get_completed_torrents(self, category=None):
"""Return a list of completed torrent dicts from qBittorrent."""
params = {"filter": "completed"}
def get_torrents(self, filter=None, category=None):
"""Return a list of torrent dicts, optionally filtered by state and/or category."""
params = {}
if filter:
params["filter"] = filter
if category:
params["category"] = category
resp = self._request("GET", "/api/v2/torrents/info", params=params)