Fix handle_completed — guard against invalid completion_on timestamp
qBittorrent returns completion_on = -1 for torrents that were never completed. datetime.fromtimestamp(-1) throws OSError on Windows. Added explicit check for negative values and try/except for safety. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -110,11 +110,15 @@ def handle_completed(qbt, cursor):
|
||||
"""
|
||||
removed = 0
|
||||
for t in qbt.torrents_info():
|
||||
if not t.completion_on:
|
||||
if not t.completion_on or t.completion_on < 0:
|
||||
continue
|
||||
|
||||
try:
|
||||
completed_dt = datetime.fromtimestamp(t.completion_on)
|
||||
except (OSError, ValueError, OverflowError):
|
||||
continue
|
||||
|
||||
thash = t.hash.lower()
|
||||
completed_dt = datetime.fromtimestamp(t.completion_on)
|
||||
|
||||
try:
|
||||
qbt.torrents_delete(torrent_hashes=thash, delete_files=False)
|
||||
|
||||
Reference in New Issue
Block a user