[downloader:http] skip files not passing filesize-min/-max (#4821)
instead of failing the download
This commit is contained in:
@@ -200,13 +200,15 @@ class HttpDownloader(DownloaderBase):
|
|||||||
self.log.warning(
|
self.log.warning(
|
||||||
"File size smaller than allowed minimum (%s < %s)",
|
"File size smaller than allowed minimum (%s < %s)",
|
||||||
size, self.minsize)
|
size, self.minsize)
|
||||||
return False
|
pathfmt.temppath = ""
|
||||||
|
return True
|
||||||
if self.maxsize and size > self.maxsize:
|
if self.maxsize and size > self.maxsize:
|
||||||
self.release_conn(response)
|
self.release_conn(response)
|
||||||
self.log.warning(
|
self.log.warning(
|
||||||
"File size larger than allowed maximum (%s > %s)",
|
"File size larger than allowed maximum (%s > %s)",
|
||||||
size, self.maxsize)
|
size, self.maxsize)
|
||||||
return False
|
pathfmt.temppath = ""
|
||||||
|
return True
|
||||||
|
|
||||||
build_path = False
|
build_path = False
|
||||||
|
|
||||||
|
|||||||
@@ -214,7 +214,8 @@ class TestHTTPDownloader(TestDownloaderBase):
|
|||||||
self.downloader.minsize = 100
|
self.downloader.minsize = 100
|
||||||
with self.assertLogs(self.downloader.log, "WARNING"):
|
with self.assertLogs(self.downloader.log, "WARNING"):
|
||||||
success = self.downloader.download(url, pathfmt)
|
success = self.downloader.download(url, pathfmt)
|
||||||
self.assertFalse(success)
|
self.assertTrue(success)
|
||||||
|
self.assertEqual(pathfmt.temppath, "")
|
||||||
|
|
||||||
def test_http_filesize_max(self):
|
def test_http_filesize_max(self):
|
||||||
url = self.address + "/jpg"
|
url = self.address + "/jpg"
|
||||||
@@ -222,7 +223,8 @@ class TestHTTPDownloader(TestDownloaderBase):
|
|||||||
self.downloader.maxsize = 100
|
self.downloader.maxsize = 100
|
||||||
with self.assertLogs(self.downloader.log, "WARNING"):
|
with self.assertLogs(self.downloader.log, "WARNING"):
|
||||||
success = self.downloader.download(url, pathfmt)
|
success = self.downloader.download(url, pathfmt)
|
||||||
self.assertFalse(success)
|
self.assertTrue(success)
|
||||||
|
self.assertEqual(pathfmt.temppath, "")
|
||||||
|
|
||||||
|
|
||||||
class TestTextDownloader(TestDownloaderBase):
|
class TestTextDownloader(TestDownloaderBase):
|
||||||
|
|||||||
Reference in New Issue
Block a user