From f510c2a43381cb3fb7542dc27dac04ee1fb219e8 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Mon, 16 Jul 2018 16:48:46 -0300 Subject: [PATCH] improve logging from review --- lbrynet/core/HTTPBlobDownloader.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lbrynet/core/HTTPBlobDownloader.py b/lbrynet/core/HTTPBlobDownloader.py index a67c255fe..f25ef1955 100644 --- a/lbrynet/core/HTTPBlobDownloader.py +++ b/lbrynet/core/HTTPBlobDownloader.py @@ -45,9 +45,7 @@ class HTTPBlobDownloader(object): @defer.inlineCallbacks def download_blob(self, blob): try: - blob_hash = yield self._download_blob(blob) - if blob_hash: - log.debug('Mirror completed download for %s', blob_hash) + yield self._download_blob(blob) self.failures = 0 except Exception as exception: self.failures += 1 @@ -61,15 +59,17 @@ class HTTPBlobDownloader(object): if not blob.get_is_verified() and not blob.is_downloading() and 'mirror' not in blob.writers: response = yield self.client.get(url_for(choice(self.servers), blob.blob_hash)) if response.code != 200: - log.error('[Mirror] Missing a blob: %s', blob.blob_hash) - self.blob_hashes.remove(blob.blob_hash) + log.debug('[Mirror] Missing a blob: %s', blob.blob_hash) + if blob.blob_hash in self.blob_hashes: + self.blob_hashes.remove(blob.blob_hash) defer.returnValue(blob.blob_hash) log.debug('[Mirror] Download started: %s', blob.blob_hash) blob.set_length(response.length) writer, finished_deferred = blob.open_for_writing('mirror') try: yield self.client.collect(response, writer.write) - except Exception, e: + log.info('Mirror completed download for %s', blob.blob_hash) + except Exception as e: writer.close(e) yield finished_deferred defer.returnValue(blob.blob_hash)