make sure the downloader always stops gracefully

This commit is contained in:
Victor Shyba 2021-11-03 15:51:51 -03:00 committed by Jack Robison
parent d6d0ebf8f4
commit 63cbcd0956

View file

@ -14,9 +14,9 @@ class BackgroundDownloader:
downloader = StreamDownloader(asyncio.get_running_loop(), self.conf, self.blob_manager, sd_hash)
try:
await downloader.start(self.node, save_stream=False)
except ValueError:
return
for blob_info in downloader.descriptor.blobs[:-1]:
await downloader.download_stream_blob(blob_info)
# for now, announcing is unnecessary because the blobs we have were announced to us, se they will be queried
# await self.storage.set_announce(sd_hash, downloader.descriptor.blobs[0].blob_hash)
except ValueError:
return
finally:
downloader.stop()