about summary refs log tree commit diff
path: root/youtube_dl/downloader
diff options
context:
space:
mode:
authorSergey M․ <dstftw@gmail.com>2017-09-14 23:19:53 +0700
committerSergey M․ <dstftw@gmail.com>2017-09-14 23:19:53 +0700
commite7c3e33456e155106ad08347d8ab9a2ecd0c8a11 (patch)
treea0b078a0be5b18c37ffbf85e88c0d958866d6f42 /youtube_dl/downloader
parent757984af90ce924f917ce9d940ebd120e95a4c4e (diff)
downloadyoutube-dl-e7c3e33456e155106ad08347d8ab9a2ecd0c8a11.tar.gz
youtube-dl-e7c3e33456e155106ad08347d8ab9a2ecd0c8a11.tar.xz
youtube-dl-e7c3e33456e155106ad08347d8ab9a2ecd0c8a11.zip
[downloader/fragment] Restart inconsistent incomplete fragment downloads (#13731)
Diffstat (limited to 'youtube_dl/downloader')
-rw-r--r--youtube_dl/downloader/fragment.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/youtube_dl/downloader/fragment.py b/youtube_dl/downloader/fragment.py
index bccc8ecc1..6f6fb4a77 100644
--- a/youtube_dl/downloader/fragment.py
+++ b/youtube_dl/downloader/fragment.py
@@ -151,10 +151,15 @@ class FragmentFD(FileDownloader):
         if self.__do_ytdl_file(ctx):
             if os.path.isfile(encodeFilename(self.ytdl_filename(ctx['filename']))):
                 self._read_ytdl_file(ctx)
+                if ctx['fragment_index'] > 0 and resume_len == 0:
+                    self.report_error(
+                        'Inconsistent state of incomplete fragment download. '
+                        'Restarting from the beginning...')
+                    ctx['fragment_index'] = resume_len = 0
+                    self._write_ytdl_file(ctx)
             else:
                 self._write_ytdl_file(ctx)
-            if ctx['fragment_index'] > 0:
-                assert resume_len > 0
+                assert ctx['fragment_index'] == 0
 
         dest_stream, tmpfilename = sanitize_open(tmpfilename, open_mode)