[downloader/http] Only check for resumability when actually resuming
authordirkf <fieldhouse@gmx.net>
Sun, 19 Mar 2023 00:51:44 +0000 (00:51 +0000)
committerdirkf <fieldhouse@gmx.net>
Sun, 19 Mar 2023 02:15:41 +0000 (02:15 +0000)
test/test_downloader_http.py
youtube_dl/downloader/http.py

index 4e6d7a2a05a5efc1d0a697ea894ed3db0c5d38cc..6af86ae4862989dc44d9cfda64e8cc35943941cb 100644 (file)
@@ -88,7 +88,7 @@ class TestHttpFD(unittest.TestCase):
         self.assertTrue(downloader.real_download(filename, {
             'url': 'http://127.0.0.1:%d/%s' % (self.port, ep),
         }))
-        self.assertEqual(os.path.getsize(encodeFilename(filename)), TEST_SIZE)
+        self.assertEqual(os.path.getsize(encodeFilename(filename)), TEST_SIZE, ep)
         try_rm(encodeFilename(filename))
 
     def download_all(self, params):
index 440471aa051d225ef14ddd6ffd832cecd71287f0..28a49b9e894fbedd99d382d52c9383b7514e9113 100644 (file)
@@ -141,7 +141,8 @@ class HttpFD(FileDownloader):
                     # Content-Range is either not present or invalid. Assuming remote webserver is
                     # trying to send the whole file, resume is not possible, so wiping the local file
                     # and performing entire redownload
-                    self.report_unable_to_resume()
+                    if range_start > 0:
+                        self.report_unable_to_resume()
                     ctx.resume_len = 0
                     ctx.open_mode = 'wb'
                 ctx.data_len = int_or_none(ctx.data.info().get('Content-length', None))