From bd3c4b1702f1bc0aa6d8a989dbf53c7ae538e30f Mon Sep 17 00:00:00 2001 From: Kasper Plougmann Date: Tue, 8 Jul 2025 21:26:40 +0200 Subject: [PATCH] Cleaner downloads --- fetch_torrents.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/fetch_torrents.py b/fetch_torrents.py index e0a63b0..8635d38 100644 --- a/fetch_torrents.py +++ b/fetch_torrents.py @@ -21,7 +21,14 @@ logging.basicConfig( watch_dir = "/watch" def download_torrent(name, url): - dest = os.path.join(watch_dir, f"{name}.torrent") + dest = os.path.join(watch_dir, f"{name}.torrent") + added = os.path.join(watch_dir, f"{name}.torrent.added") + + # Skip if already processed or queued + if dest.exists() or added.exists(): + logging.info("Skip %s – torrent already present.", dest.name) + return False + try: logging.info(f"Fetching {url} ...") r = requests.get(url, timeout=30)