Actually delete partial file when cancelling.

Calling run() with CANCELLED state only returns without performing any
work. The CANCELLING state actually deletes the partial file and
recycles the task.
This commit is contained in:
auouymous 2021-10-11 19:53:00 -06:00
parent 69e242184c
commit 263c4ad9fe
1 changed files with 2 additions and 3 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