From 3dd99fdc92ee755bdfd939ccfa52dc3e09297921 Mon Sep 17 00:00:00 2001 From: Jack Date: Thu, 20 Oct 2016 15:40:35 -0400 Subject: [PATCH 1/6] upload unavailable streams to reflector on startup --- lbrynet/core/log_support.py | 8 +--- .../EncryptedFileDownloader.py | 42 ++++++++++++++++++- lbrynet/reflector/client/client.py | 11 +++-- 3 files changed, 49 insertions(+), 12 deletions(-) diff --git a/lbrynet/core/log_support.py b/lbrynet/core/log_support.py index 2f2a5c75b..becb698c8 100644 --- a/lbrynet/core/log_support.py +++ b/lbrynet/core/log_support.py @@ -77,13 +77,7 @@ def disable_third_party_loggers(): logging.getLogger('BitcoinRPC').setLevel(logging.INFO) def disable_noisy_loggers(): - logging.getLogger('lbrynet.analytics.api').setLevel(logging.INFO) - logging.getLogger('lbrynet.core').setLevel(logging.INFO) - logging.getLogger('lbrynet.dht').setLevel(logging.INFO) - logging.getLogger('lbrynet.lbrynet_daemon').setLevel(logging.INFO) - logging.getLogger('lbrynet.core.Wallet').setLevel(logging.INFO) - logging.getLogger('lbrynet.lbryfile').setLevel(logging.INFO) - logging.getLogger('lbrynet.lbryfilemanager').setLevel(logging.INFO) + logging.getLogger('lbrynet').setLevel(logging.INFO) @_log_decorator diff --git a/lbrynet/lbryfilemanager/EncryptedFileDownloader.py b/lbrynet/lbryfilemanager/EncryptedFileDownloader.py index 5546787c4..c936dd1d1 100644 --- a/lbrynet/lbryfilemanager/EncryptedFileDownloader.py +++ b/lbrynet/lbryfilemanager/EncryptedFileDownloader.py @@ -1,16 +1,21 @@ """ Download LBRY Files from LBRYnet and save them to disk. """ +import random +import logging from zope.interface import implements +from twisted.internet import defer, reactor + from lbrynet.core.client.StreamProgressManager import FullStreamProgressManager from lbrynet.core.StreamDescriptor import StreamMetadata from lbrynet.lbryfile.client.EncryptedFileDownloader import EncryptedFileSaver, EncryptedFileDownloader from lbrynet.lbryfilemanager.EncryptedFileStatusReport import EncryptedFileStatusReport from lbrynet.interfaces import IStreamDownloaderFactory from lbrynet.lbryfile.StreamDescriptor import save_sd_info -from twisted.internet import defer -import logging +from lbrynet.reflector import BlobClientFactory, ClientFactory +from lbrynet.conf import REFLECTOR_SERVERS + log = logging.getLogger(__name__) @@ -63,8 +68,41 @@ class ManagedEncryptedFileDownloader(EncryptedFileSaver): d.addCallbacks(_save_claim_id, lambda err: _notify_bad_claim(name, txid)) return d + def _check_file_availability(): + reflector_server = random.choice(REFLECTOR_SERVERS) + reflector_address, reflector_port = reflector_server[0], reflector_server[1] + factory = BlobClientFactory( + self.blob_manager, + [self.sd_hash] + ) + d = reactor.resolve(reflector_address) + d.addCallback(lambda ip: reactor.connectTCP(ip, reflector_port, factory)) + d.addCallback(lambda _: factory.finished_deferred) + d.addCallback(lambda _: _reflect_if_unavailable(factory.sent_blobs)) + return d + + def _reflect_if_unavailable(sent_blobs): + if not sent_blobs: + log.info("lbry://%s is available", self.uri) + return defer.succeed(True) + if self.stream_hash is None: + return defer.fail(Exception("no stream hash")) + log.info("Reflecting previously unavailable stream: %s" % self.stream_hash) + reflector_server = random.choice(REFLECTOR_SERVERS) + reflector_address, reflector_port = reflector_server[0], reflector_server[1] + factory = ClientFactory( + self.blob_manager, + self.stream_info_manager, + self.stream_hash + ) + d = reactor.resolve(reflector_address) + d.addCallback(lambda ip: reactor.connectTCP(ip, reflector_port, factory)) + d.addCallback(lambda _: factory.finished_deferred) + return d + d.addCallback(_save_sd_hash) d.addCallback(lambda r: _save_claim(r[0], r[1]) if r else None) + d.addCallback(lambda _: _check_file_availability()) d.addCallback(lambda _: self.lbry_file_manager.get_lbry_file_status(self)) def restore_status(status): diff --git a/lbrynet/reflector/client/client.py b/lbrynet/reflector/client/client.py index 23d497456..0a4e4b599 100644 --- a/lbrynet/reflector/client/client.py +++ b/lbrynet/reflector/client/client.py @@ -284,6 +284,7 @@ class BlobReflectorClient(Protocol): self.file_sender = None self.producer = None self.streaming = False + self.blobs_where_sent = False d = self.send_handshake() d.addErrback(lambda err: log.warning("An error occurred immediately: %s", err.getTraceback())) @@ -302,10 +303,12 @@ class BlobReflectorClient(Protocol): def connectionLost(self, reason): if reason.check(error.ConnectionDone): - log.debug('Finished sending data via reflector') + self.factory.sent_blobs = self.blobs_where_sent + if self.factory.sent_blobs: + log.info('Finished sending data via reflector') self.factory.finished_deferred.callback(True) else: - log.debug('reflector finished: %s', reason) + log.info('Reflector finished: %s', reason) self.factory.finished_deferred.callback(reason) # IConsumer stuff @@ -374,6 +377,7 @@ class BlobReflectorClient(Protocol): if 'send_blob' not in response_dict: raise ValueError("I don't know whether to send the blob or not!") if response_dict['send_blob'] is True: + self.blobs_where_sent = True self.file_sender = FileSender() return defer.succeed(True) else: @@ -395,7 +399,7 @@ class BlobReflectorClient(Protocol): raise ValueError("Couldn't open that blob for some reason. blob_hash: {}".format(blob.blob_hash)) def send_blob_info(self): - log.info("Send blob info for %s", self.next_blob_to_send.blob_hash) + log.debug("Send blob info for %s", self.next_blob_to_send.blob_hash) assert self.next_blob_to_send is not None, "need to have a next blob to send at this point" log.debug('sending blob info') self.write(json.dumps({ @@ -431,6 +435,7 @@ class BlobReflectorClientFactory(ClientFactory): self.blob_manager = blob_manager self.blobs = blobs self.p = None + self.sent_blobs = False self.finished_deferred = defer.Deferred() def buildProtocol(self, addr): From 369cd516c05e7b7326ab5ad57ad7eeef04b20478 Mon Sep 17 00:00:00 2001 From: Jack Date: Wed, 26 Oct 2016 16:17:01 -0400 Subject: [PATCH 2/6] move availability check and fix from ManagedEncryptedFileDownloader to ReflectorAvailabilityHelper --- .../EncryptedFileDownloader.py | 38 ++------------- lbrynet/reflector/__init__.py | 1 + lbrynet/reflector/client/client.py | 10 ++-- lbrynet/reflector/util.py | 47 +++++++++++++++++++ 4 files changed, 58 insertions(+), 38 deletions(-) create mode 100644 lbrynet/reflector/util.py diff --git a/lbrynet/lbryfilemanager/EncryptedFileDownloader.py b/lbrynet/lbryfilemanager/EncryptedFileDownloader.py index c936dd1d1..39646266c 100644 --- a/lbrynet/lbryfilemanager/EncryptedFileDownloader.py +++ b/lbrynet/lbryfilemanager/EncryptedFileDownloader.py @@ -13,10 +13,9 @@ from lbrynet.lbryfile.client.EncryptedFileDownloader import EncryptedFileSaver, from lbrynet.lbryfilemanager.EncryptedFileStatusReport import EncryptedFileStatusReport from lbrynet.interfaces import IStreamDownloaderFactory from lbrynet.lbryfile.StreamDescriptor import save_sd_info -from lbrynet.reflector import BlobClientFactory, ClientFactory +from lbrynet.reflector import BlobClientFactory, ClientFactory, ReflectorAvailabilityHelper from lbrynet.conf import REFLECTOR_SERVERS - log = logging.getLogger(__name__) @@ -68,41 +67,10 @@ class ManagedEncryptedFileDownloader(EncryptedFileSaver): d.addCallbacks(_save_claim_id, lambda err: _notify_bad_claim(name, txid)) return d - def _check_file_availability(): - reflector_server = random.choice(REFLECTOR_SERVERS) - reflector_address, reflector_port = reflector_server[0], reflector_server[1] - factory = BlobClientFactory( - self.blob_manager, - [self.sd_hash] - ) - d = reactor.resolve(reflector_address) - d.addCallback(lambda ip: reactor.connectTCP(ip, reflector_port, factory)) - d.addCallback(lambda _: factory.finished_deferred) - d.addCallback(lambda _: _reflect_if_unavailable(factory.sent_blobs)) - return d - def _reflect_if_unavailable(sent_blobs): - if not sent_blobs: - log.info("lbry://%s is available", self.uri) - return defer.succeed(True) - if self.stream_hash is None: - return defer.fail(Exception("no stream hash")) - log.info("Reflecting previously unavailable stream: %s" % self.stream_hash) - reflector_server = random.choice(REFLECTOR_SERVERS) - reflector_address, reflector_port = reflector_server[0], reflector_server[1] - factory = ClientFactory( - self.blob_manager, - self.stream_info_manager, - self.stream_hash - ) - d = reactor.resolve(reflector_address) - d.addCallback(lambda ip: reactor.connectTCP(ip, reflector_port, factory)) - d.addCallback(lambda _: factory.finished_deferred) - return d d.addCallback(_save_sd_hash) d.addCallback(lambda r: _save_claim(r[0], r[1]) if r else None) - d.addCallback(lambda _: _check_file_availability()) d.addCallback(lambda _: self.lbry_file_manager.get_lbry_file_status(self)) def restore_status(status): @@ -115,6 +83,10 @@ class ManagedEncryptedFileDownloader(EncryptedFileSaver): return defer.succeed(True) d.addCallback(restore_status) + + reflector_server = random.choice(REFLECTOR_SERVERS) + + d.addCallback(lambda _: ReflectorAvailabilityHelper.check_and_restore_availability(self, reflector_server)) return d def stop(self, err=None, change_status=True): diff --git a/lbrynet/reflector/__init__.py b/lbrynet/reflector/__init__.py index ccabe2e6f..9d32ccb6d 100644 --- a/lbrynet/reflector/__init__.py +++ b/lbrynet/reflector/__init__.py @@ -1,3 +1,4 @@ from lbrynet.reflector.server.server import ReflectorServerFactory as ServerFactory from lbrynet.reflector.client.client import EncryptedFileReflectorClientFactory as ClientFactory from lbrynet.reflector.client.client import BlobReflectorClientFactory as BlobClientFactory +from lbrynet.reflector.util import ReflectorAvailabilityHelper \ No newline at end of file diff --git a/lbrynet/reflector/client/client.py b/lbrynet/reflector/client/client.py index 0a4e4b599..3f855af90 100644 --- a/lbrynet/reflector/client/client.py +++ b/lbrynet/reflector/client/client.py @@ -126,7 +126,7 @@ class EncryptedFileReflectorClient(Protocol): def set_blobs(blob_hashes): for blob_hash, position, iv, length in blob_hashes: - log.info("Preparing to send %s", blob_hash) + log.debug("Preparing to send %s", blob_hash) if blob_hash is not None: self.blob_hashes_to_send.append(blob_hash) @@ -209,7 +209,7 @@ class EncryptedFileReflectorClient(Protocol): raise ValueError("Couldn't open that blob for some reason. blob_hash: {}".format(blob.blob_hash)) def send_blob_info(self): - log.info("Send blob info for %s", self.next_blob_to_send.blob_hash) + log.debug("Send blob info for %s", self.next_blob_to_send.blob_hash) assert self.next_blob_to_send is not None, "need to have a next blob to send at this point" log.debug('sending blob info') self.write(json.dumps({ @@ -284,7 +284,7 @@ class BlobReflectorClient(Protocol): self.file_sender = None self.producer = None self.streaming = False - self.blobs_where_sent = False + self.sent_blobs = False d = self.send_handshake() d.addErrback(lambda err: log.warning("An error occurred immediately: %s", err.getTraceback())) @@ -303,7 +303,7 @@ class BlobReflectorClient(Protocol): def connectionLost(self, reason): if reason.check(error.ConnectionDone): - self.factory.sent_blobs = self.blobs_where_sent + self.factory.sent_blobs = self.sent_blobs if self.factory.sent_blobs: log.info('Finished sending data via reflector') self.factory.finished_deferred.callback(True) @@ -358,6 +358,7 @@ class BlobReflectorClient(Protocol): return defer.succeed(None) def start_transfer(self): + self.sent_blobs = True self.write(json.dumps({})) assert self.read_handle is not None, "self.read_handle was None when trying to start the transfer" d = self.file_sender.beginFileTransfer(self.read_handle, self) @@ -377,7 +378,6 @@ class BlobReflectorClient(Protocol): if 'send_blob' not in response_dict: raise ValueError("I don't know whether to send the blob or not!") if response_dict['send_blob'] is True: - self.blobs_where_sent = True self.file_sender = FileSender() return defer.succeed(True) else: diff --git a/lbrynet/reflector/util.py b/lbrynet/reflector/util.py new file mode 100644 index 000000000..a3fe519f1 --- /dev/null +++ b/lbrynet/reflector/util.py @@ -0,0 +1,47 @@ +import logging +from twisted.internet import reactor, defer +from lbrynet.reflector import BlobClientFactory, ClientFactory + +log = logging.getLogger(__name__) + + +class ReflectorAvailabilityHelper(object): + @staticmethod + def _check_if_reflector_has_stream(lbry_file, reflector_server): + reflector_address, reflector_port = reflector_server[0], reflector_server[1] + factory = BlobClientFactory( + lbry_file.blob_manager, + [lbry_file.sd_hash] + ) + d = reactor.resolve(reflector_address) + d.addCallback(lambda ip: reactor.connectTCP(ip, reflector_port, factory)) + d.addCallback(lambda _: factory.finished_deferred) + d.addCallback(lambda _: not factory.sent_blobs) + return d + + @staticmethod + def _reflect_stream(lbry_file, reflector_server): + reflector_address, reflector_port = reflector_server[0], reflector_server[1] + factory = ClientFactory( + lbry_file.blob_manager, + lbry_file.stream_info_manager, + lbry_file.stream_hash + ) + d = reactor.resolve(reflector_address) + d.addCallback(lambda ip: reactor.connectTCP(ip, reflector_port, factory)) + d.addCallback(lambda _: factory.finished_deferred) + return d + + @classmethod + def _reflect_if_unavailable(cls, reflector_has_stream, lbry_file, reflector_server): + if reflector_has_stream: + log.info("lbry://%s is available", lbry_file.uri) + return defer.succeed(False) + log.info("lbry://%s is unavailable, reflecting it", lbry_file.uri) + return cls._reflect_stream(lbry_file, reflector_server) + + @classmethod + def check_and_restore_availability(cls, lbry_file, reflector_server): + d = cls._check_if_reflector_has_stream(lbry_file, reflector_server) + d.addCallback(lambda send_stream: cls._reflect_if_unavailable(send_stream, lbry_file, reflector_server)) + return d From d4785849e151aa9ff64141c05cbaa3b90c9f481e Mon Sep 17 00:00:00 2001 From: Jack Date: Fri, 28 Oct 2016 14:22:37 -0400 Subject: [PATCH 3/6] remove unused imports --- lbrynet/lbryfilemanager/EncryptedFileDownloader.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lbrynet/lbryfilemanager/EncryptedFileDownloader.py b/lbrynet/lbryfilemanager/EncryptedFileDownloader.py index 39646266c..4103cc911 100644 --- a/lbrynet/lbryfilemanager/EncryptedFileDownloader.py +++ b/lbrynet/lbryfilemanager/EncryptedFileDownloader.py @@ -5,7 +5,7 @@ import random import logging from zope.interface import implements -from twisted.internet import defer, reactor +from twisted.internet import defer from lbrynet.core.client.StreamProgressManager import FullStreamProgressManager from lbrynet.core.StreamDescriptor import StreamMetadata @@ -13,7 +13,7 @@ from lbrynet.lbryfile.client.EncryptedFileDownloader import EncryptedFileSaver, from lbrynet.lbryfilemanager.EncryptedFileStatusReport import EncryptedFileStatusReport from lbrynet.interfaces import IStreamDownloaderFactory from lbrynet.lbryfile.StreamDescriptor import save_sd_info -from lbrynet.reflector import BlobClientFactory, ClientFactory, ReflectorAvailabilityHelper +from lbrynet.reflector import ReflectorAvailabilityHelper from lbrynet.conf import REFLECTOR_SERVERS log = logging.getLogger(__name__) From 035a1cf758ae863b0544a205693be9077fab55a9 Mon Sep 17 00:00:00 2001 From: Jack Date: Fri, 28 Oct 2016 15:48:51 -0400 Subject: [PATCH 4/6] feedback from job --- .../EncryptedFileDownloader.py | 4 +- lbrynet/reflector/__init__.py | 2 +- lbrynet/reflector/reupload.py | 45 ++++++++++++++++++ lbrynet/reflector/util.py | 47 ------------------- 4 files changed, 48 insertions(+), 50 deletions(-) create mode 100644 lbrynet/reflector/reupload.py delete mode 100644 lbrynet/reflector/util.py diff --git a/lbrynet/lbryfilemanager/EncryptedFileDownloader.py b/lbrynet/lbryfilemanager/EncryptedFileDownloader.py index 4103cc911..db55ac3ad 100644 --- a/lbrynet/lbryfilemanager/EncryptedFileDownloader.py +++ b/lbrynet/lbryfilemanager/EncryptedFileDownloader.py @@ -13,7 +13,7 @@ from lbrynet.lbryfile.client.EncryptedFileDownloader import EncryptedFileSaver, from lbrynet.lbryfilemanager.EncryptedFileStatusReport import EncryptedFileStatusReport from lbrynet.interfaces import IStreamDownloaderFactory from lbrynet.lbryfile.StreamDescriptor import save_sd_info -from lbrynet.reflector import ReflectorAvailabilityHelper +from lbrynet.reflector import reupload from lbrynet.conf import REFLECTOR_SERVERS log = logging.getLogger(__name__) @@ -86,7 +86,7 @@ class ManagedEncryptedFileDownloader(EncryptedFileSaver): reflector_server = random.choice(REFLECTOR_SERVERS) - d.addCallback(lambda _: ReflectorAvailabilityHelper.check_and_restore_availability(self, reflector_server)) + d.addCallback(lambda _: reupload.check_and_restore_availability(self, reflector_server)) return d def stop(self, err=None, change_status=True): diff --git a/lbrynet/reflector/__init__.py b/lbrynet/reflector/__init__.py index 9d32ccb6d..a2f9c186a 100644 --- a/lbrynet/reflector/__init__.py +++ b/lbrynet/reflector/__init__.py @@ -1,4 +1,4 @@ from lbrynet.reflector.server.server import ReflectorServerFactory as ServerFactory from lbrynet.reflector.client.client import EncryptedFileReflectorClientFactory as ClientFactory from lbrynet.reflector.client.client import BlobReflectorClientFactory as BlobClientFactory -from lbrynet.reflector.util import ReflectorAvailabilityHelper \ No newline at end of file +from lbrynet.reflector import reupload \ No newline at end of file diff --git a/lbrynet/reflector/reupload.py b/lbrynet/reflector/reupload.py new file mode 100644 index 000000000..8a95995c2 --- /dev/null +++ b/lbrynet/reflector/reupload.py @@ -0,0 +1,45 @@ +import logging +from twisted.internet import reactor, defer +from lbrynet.reflector import BlobClientFactory, ClientFactory + +log = logging.getLogger(__name__) + + +def _check_if_reflector_has_stream(lbry_file, reflector_server): + reflector_address, reflector_port = reflector_server[0], reflector_server[1] + factory = BlobClientFactory( + lbry_file.blob_manager, + [lbry_file.sd_hash] + ) + d = reactor.resolve(reflector_address) + d.addCallback(lambda ip: reactor.connectTCP(ip, reflector_port, factory)) + d.addCallback(lambda _: factory.finished_deferred) + d.addCallback(lambda _: not factory.sent_blobs) + return d + + +def _reflect_stream(lbry_file, reflector_server): + reflector_address, reflector_port = reflector_server[0], reflector_server[1] + factory = ClientFactory( + lbry_file.blob_manager, + lbry_file.stream_info_manager, + lbry_file.stream_hash + ) + d = reactor.resolve(reflector_address) + d.addCallback(lambda ip: reactor.connectTCP(ip, reflector_port, factory)) + d.addCallback(lambda _: factory.finished_deferred) + return d + + +def _reflect_if_unavailable(reflector_has_stream, lbry_file, reflector_server): + if reflector_has_stream: + log.info("lbry://%s is available", lbry_file.uri) + return defer.succeed(False) + log.info("lbry://%s is unavailable, reflecting it", lbry_file.uri) + return _reflect_stream(lbry_file, reflector_server) + + +def check_and_restore_availability(cls, lbry_file, reflector_server): + d = cls._check_if_reflector_has_stream(lbry_file, reflector_server) + d.addCallback(lambda send_stream: _reflect_if_unavailable(send_stream, lbry_file, reflector_server)) + return d diff --git a/lbrynet/reflector/util.py b/lbrynet/reflector/util.py deleted file mode 100644 index a3fe519f1..000000000 --- a/lbrynet/reflector/util.py +++ /dev/null @@ -1,47 +0,0 @@ -import logging -from twisted.internet import reactor, defer -from lbrynet.reflector import BlobClientFactory, ClientFactory - -log = logging.getLogger(__name__) - - -class ReflectorAvailabilityHelper(object): - @staticmethod - def _check_if_reflector_has_stream(lbry_file, reflector_server): - reflector_address, reflector_port = reflector_server[0], reflector_server[1] - factory = BlobClientFactory( - lbry_file.blob_manager, - [lbry_file.sd_hash] - ) - d = reactor.resolve(reflector_address) - d.addCallback(lambda ip: reactor.connectTCP(ip, reflector_port, factory)) - d.addCallback(lambda _: factory.finished_deferred) - d.addCallback(lambda _: not factory.sent_blobs) - return d - - @staticmethod - def _reflect_stream(lbry_file, reflector_server): - reflector_address, reflector_port = reflector_server[0], reflector_server[1] - factory = ClientFactory( - lbry_file.blob_manager, - lbry_file.stream_info_manager, - lbry_file.stream_hash - ) - d = reactor.resolve(reflector_address) - d.addCallback(lambda ip: reactor.connectTCP(ip, reflector_port, factory)) - d.addCallback(lambda _: factory.finished_deferred) - return d - - @classmethod - def _reflect_if_unavailable(cls, reflector_has_stream, lbry_file, reflector_server): - if reflector_has_stream: - log.info("lbry://%s is available", lbry_file.uri) - return defer.succeed(False) - log.info("lbry://%s is unavailable, reflecting it", lbry_file.uri) - return cls._reflect_stream(lbry_file, reflector_server) - - @classmethod - def check_and_restore_availability(cls, lbry_file, reflector_server): - d = cls._check_if_reflector_has_stream(lbry_file, reflector_server) - d.addCallback(lambda send_stream: cls._reflect_if_unavailable(send_stream, lbry_file, reflector_server)) - return d From 110a9b1e0f598cf2d1bc01dd827eda704265cf9d Mon Sep 17 00:00:00 2001 From: Jack Date: Fri, 28 Oct 2016 15:56:22 -0400 Subject: [PATCH 5/6] whoops --- lbrynet/reflector/reupload.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lbrynet/reflector/reupload.py b/lbrynet/reflector/reupload.py index 8a95995c2..97e401c6c 100644 --- a/lbrynet/reflector/reupload.py +++ b/lbrynet/reflector/reupload.py @@ -39,7 +39,7 @@ def _reflect_if_unavailable(reflector_has_stream, lbry_file, reflector_server): return _reflect_stream(lbry_file, reflector_server) -def check_and_restore_availability(cls, lbry_file, reflector_server): - d = cls._check_if_reflector_has_stream(lbry_file, reflector_server) +def check_and_restore_availability(lbry_file, reflector_server): + d = _check_if_reflector_has_stream(lbry_file, reflector_server) d.addCallback(lambda send_stream: _reflect_if_unavailable(send_stream, lbry_file, reflector_server)) return d From da601818a362f3b72d9c8f089be46417338890d2 Mon Sep 17 00:00:00 2001 From: Jack Date: Fri, 28 Oct 2016 16:47:45 -0400 Subject: [PATCH 6/6] return from restore_status properly --- lbrynet/lbryfilemanager/EncryptedFileDownloader.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lbrynet/lbryfilemanager/EncryptedFileDownloader.py b/lbrynet/lbryfilemanager/EncryptedFileDownloader.py index db55ac3ad..7ce5adb9d 100644 --- a/lbrynet/lbryfilemanager/EncryptedFileDownloader.py +++ b/lbrynet/lbryfilemanager/EncryptedFileDownloader.py @@ -14,7 +14,7 @@ from lbrynet.lbryfilemanager.EncryptedFileStatusReport import EncryptedFileStatu from lbrynet.interfaces import IStreamDownloaderFactory from lbrynet.lbryfile.StreamDescriptor import save_sd_info from lbrynet.reflector import reupload -from lbrynet.conf import REFLECTOR_SERVERS +from lbrynet.conf import settings log = logging.getLogger(__name__) @@ -67,10 +67,11 @@ class ManagedEncryptedFileDownloader(EncryptedFileSaver): d.addCallbacks(_save_claim_id, lambda err: _notify_bad_claim(name, txid)) return d - + reflector_server = random.choice(settings.reflector_servers) d.addCallback(_save_sd_hash) d.addCallback(lambda r: _save_claim(r[0], r[1]) if r else None) + d.addCallback(lambda _: reupload.check_and_restore_availability(self, reflector_server)) d.addCallback(lambda _: self.lbry_file_manager.get_lbry_file_status(self)) def restore_status(status): @@ -83,10 +84,6 @@ class ManagedEncryptedFileDownloader(EncryptedFileSaver): return defer.succeed(True) d.addCallback(restore_status) - - reflector_server = random.choice(REFLECTOR_SERVERS) - - d.addCallback(lambda _: reupload.check_and_restore_availability(self, reflector_server)) return d def stop(self, err=None, change_status=True):