From 5d2861fcf085b6a2123267b846344045b68245ca Mon Sep 17 00:00:00 2001 From: kannibalox Date: Fri, 13 Oct 2023 16:12:58 -0400 Subject: [PATCH] Fix loading torrent files --- src/PtpUploader/Job/LoadFile.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/PtpUploader/Job/LoadFile.py b/src/PtpUploader/Job/LoadFile.py index 006b70f8..c4077440 100644 --- a/src/PtpUploader/Job/LoadFile.py +++ b/src/PtpUploader/Job/LoadFile.py @@ -12,7 +12,8 @@ def load_json_release(path: Path): - data: Dict = json.load(path.open()) + with path.open() as fh: + data: Dict = json.load(fh) release = ReleaseInfo() allowed_fields: List[str] = [ "ImdbId", @@ -36,6 +37,13 @@ def load_json_release(path: Path): release.save() path.unlink() +def load_torrent_release(path: Path): + release = ReleaseInfo() + release.AnnouncementSourceName = "torrent" + release.SourceTorrentFilePath = path + release.JobRunningState = ReleaseInfo.JobState.WaitingForStart + release.save() + path.unlink() def scan_dir(): path = Path(Settings.GetAnnouncementWatchPath()) @@ -45,7 +53,7 @@ def scan_dir(): load_json_release(child) continue except json.decoder.JSONDecodeError: - pass + logger.debug("Cannot load %r as JSON, attempting .torrent check", child) try: load_torrent_release(child) continue