always delete file from downloads if download was not complete

This commit is contained in:
Jack Robison 2019-02-03 16:20:07 -05:00
parent e5af041627
commit dcd78bd86e
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2

View file

@ -193,6 +193,10 @@ class StreamManager:
return stream return stream
async def delete_stream(self, stream: ManagedStream, delete_file: typing.Optional[bool] = False): async def delete_stream(self, stream: ManagedStream, delete_file: typing.Optional[bool] = False):
stream_finished = False if not stream.finished and stream.downloader\
else (stream.downloader and stream.downloader.stream_finished_event.is_set())
if not stream_finished:
delete_file = True
stream.stop_download() stream.stop_download()
self.streams.remove(stream) self.streams.remove(stream)
await self.storage.delete_stream(stream.descriptor) await self.storage.delete_stream(stream.descriptor)