From ea78f67860b559915d27feb5c93a53c271b9b642 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Fri, 17 Nov 2023 15:56:00 +0100 Subject: [PATCH] [downloader:http] skip files not passing filesize-min/-max (#4821) instead of failing the download --- gallery_dl/downloader/http.py | 6 ++++-- test/test_downloader.py | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/gallery_dl/downloader/http.py b/gallery_dl/downloader/http.py index 30ac0016..f493947e 100644 --- a/gallery_dl/downloader/http.py +++ b/gallery_dl/downloader/http.py @@ -200,13 +200,15 @@ class HttpDownloader(DownloaderBase): self.log.warning( "File size smaller than allowed minimum (%s < %s)", size, self.minsize) - return False + pathfmt.temppath = "" + return True if self.maxsize and size > self.maxsize: self.release_conn(response) self.log.warning( "File size larger than allowed maximum (%s > %s)", size, self.maxsize) - return False + pathfmt.temppath = "" + return True build_path = False diff --git a/test/test_downloader.py b/test/test_downloader.py index 840e0780..f10465e5 100644 --- a/test/test_downloader.py +++ b/test/test_downloader.py @@ -214,7 +214,8 @@ class TestHTTPDownloader(TestDownloaderBase): self.downloader.minsize = 100 with self.assertLogs(self.downloader.log, "WARNING"): success = self.downloader.download(url, pathfmt) - self.assertFalse(success) + self.assertTrue(success) + self.assertEqual(pathfmt.temppath, "") def test_http_filesize_max(self): url = self.address + "/jpg" @@ -222,7 +223,8 @@ class TestHTTPDownloader(TestDownloaderBase): self.downloader.maxsize = 100 with self.assertLogs(self.downloader.log, "WARNING"): success = self.downloader.download(url, pathfmt) - self.assertFalse(success) + self.assertTrue(success) + self.assertEqual(pathfmt.temppath, "") class TestTextDownloader(TestDownloaderBase):