From 7c8ad0fe301a5b17db526b090e6d5284843836dd Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Tue, 5 Feb 2019 15:26:14 -0500 Subject: [PATCH] fix deleting incomplete downloads upon stop fix deleting previous streams (not assembled/published files) for a claim being updated --- lbrynet/stream/assembler.py | 2 +- lbrynet/stream/managed_stream.py | 4 ++++ lbrynet/stream/stream_manager.py | 4 ---- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lbrynet/stream/assembler.py b/lbrynet/stream/assembler.py index 8b11ecb7e..356a8af76 100644 --- a/lbrynet/stream/assembler.py +++ b/lbrynet/stream/assembler.py @@ -15,7 +15,7 @@ log = logging.getLogger(__name__) def _get_next_available_file_name(download_directory: str, file_name: str) -> str: - base_name, ext = os.path.splitext(file_name) + base_name, ext = os.path.splitext(os.path.basename(file_name)) i = 0 while os.path.isfile(os.path.join(download_directory, file_name)): i += 1 diff --git a/lbrynet/stream/managed_stream.py b/lbrynet/stream/managed_stream.py index 4c166589e..e8965318a 100644 --- a/lbrynet/stream/managed_stream.py +++ b/lbrynet/stream/managed_stream.py @@ -170,6 +170,10 @@ class ManagedStream: def stop_download(self): if self.downloader: self.downloader.stop() + if not self.downloader.stream_finished_event.is_set() and self.downloader.wrote_bytes_event.is_set(): + path = os.path.join(self.download_directory, self.file_name) + if os.path.isfile(path): + os.remove(path) if not self.finished: self.update_status(self.STATUS_STOPPED) diff --git a/lbrynet/stream/stream_manager.py b/lbrynet/stream/stream_manager.py index 89b14fee3..4adad9639 100644 --- a/lbrynet/stream/stream_manager.py +++ b/lbrynet/stream/stream_manager.py @@ -194,10 +194,6 @@ class StreamManager: return stream 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() self.streams.remove(stream) await self.storage.delete_stream(stream.descriptor)