From b37db5397e30e1ff977dd012ae844e64b7aedb99 Mon Sep 17 00:00:00 2001 From: Vladimir Buzalka Date: Mon, 2 Mar 2026 07:02:21 +0100 Subject: [PATCH] =?UTF-8?q?Fix=20handle=5Fcompleted=20=E2=80=94=20guard=20?= =?UTF-8?q?against=20invalid=20completion=5Fon=20timestamp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- Seedbox/70 Manager.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Seedbox/70 Manager.py b/Seedbox/70 Manager.py index ad2044f..ebd3125 100644 --- a/Seedbox/70 Manager.py +++ b/Seedbox/70 Manager.py @@ -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)