Merge pull request #1171 from auouymous/fix-1147

Fix youtube-dl re-download after a failed download
This commit is contained in:
auouymous 2021-10-28 03:27:56 -07:00 committed by GitHub
commit ce99daf065
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 7 deletions

View File

@ -624,10 +624,9 @@ class DownloadTask(object):
with self:
# Cancelling directly is allowed if the task isn't currently downloading
if self.status in (self.QUEUED, self.PAUSED, self.FAILED):
self.status = self.CANCELLED
# Call run, so the partial file gets deleted
self.status = self.CANCELLING
# Call run, so the partial file gets deleted, and task recycled
self.run()
self.recycle()
# Otherwise request cancellation
elif self.status == self.DOWNLOADING:
self.status = self.CANCELLING
@ -954,10 +953,6 @@ class DownloadTask(object):
self.status = DownloadTask.FAILED
self.__episode._download_error = self.error_message
# Delete empty partial files, they prevent streaming after a download failure (live stream)
if util.calculate_size(self.filename) == 0:
util.delete_file(self.tempname)
# cancelled/paused -- update state to mark it as safe to manipulate this task again
elif self.status == DownloadTask.PAUSING:
self.status = DownloadTask.PAUSED

View File

@ -2125,6 +2125,11 @@ class gPodder(BuilderWidget, dbus.service.Object):
for episode in episodes:
episode._download_error = None
if episode.download_task is not None and episode.download_task.status == episode.download_task.FAILED:
# Cancel failed task and remove from progress list
episode.download_task.cancel()
self.cleanup_downloads()
player = self.episode_player(episode)
try: