diff --git a/lbrynet/core/BlobManager.py b/lbrynet/core/BlobManager.py index a3d977767..5a2afb713 100644 --- a/lbrynet/core/BlobManager.py +++ b/lbrynet/core/BlobManager.py @@ -111,6 +111,7 @@ class DiskBlobManager(BlobManager): """Return a blob identified by blob_hash, which may be a new blob or a blob that is already on the hard disk """ + assert length is None or isinstance(length, int) if blob_hash in self.blobs: return defer.succeed(self.blobs[blob_hash]) return self._make_new_blob(blob_hash, length) @@ -216,7 +217,7 @@ class DiskBlobManager(BlobManager): for blob_hash, being_deleted in self.blob_hashes_to_delete.items(): if being_deleted is False: self.blob_hashes_to_delete[blob_hash] = True - d = self.get_blob(blob_hash, True) + d = self.get_blob(blob_hash) d.addCallbacks( delete, set_not_deleting, callbackArgs=(blob_hash,), errbackArgs=(blob_hash,)) @@ -270,7 +271,7 @@ class DiskBlobManager(BlobManager): @defer.inlineCallbacks def _completed_blobs(self, blobhashes_to_check): """Returns of the blobhashes_to_check, which are valid""" - blobs = yield defer.DeferredList([self.get_blob(b, True) for b in blobhashes_to_check]) + blobs = yield defer.DeferredList([self.get_blob(b) for b in blobhashes_to_check]) blob_hashes = [b.blob_hash for success, b in blobs if success and b.verified] defer.returnValue(blob_hashes) diff --git a/lbrynet/lbryfile/client/EncryptedFileDownloader.py b/lbrynet/lbryfile/client/EncryptedFileDownloader.py index 092c5ae8a..fba1c0461 100644 --- a/lbrynet/lbryfile/client/EncryptedFileDownloader.py +++ b/lbrynet/lbryfile/client/EncryptedFileDownloader.py @@ -139,7 +139,9 @@ class EncryptedFileDownloaderFactory(object): def can_download(self, sd_validator): return True - def make_downloader(self, metadata, data_rate, payment_rate_manager, **kwargs): + def make_downloader(self, metadata, options, payment_rate_manager, **kwargs): + assert len(options) == 1 + data_rate = options[0] payment_rate_manager.min_blob_data_payment_rate = data_rate def save_source_if_blob(stream_hash): diff --git a/lbrynet/lbryfile/client/EncryptedFileOptions.py b/lbrynet/lbryfile/client/EncryptedFileOptions.py index f71457dfd..bc1d4ad99 100644 --- a/lbrynet/lbryfile/client/EncryptedFileOptions.py +++ b/lbrynet/lbryfile/client/EncryptedFileOptions.py @@ -43,17 +43,5 @@ class EncryptedFileOptions(object): prm.base.min_blob_data_payment_rate, get_default_data_rate_description() ), - DownloadOption( - [ - DownloadOptionChoice(bool, - None, - None, - bool_options_description=("Allow", "Disallow")), - ], - "Allow reuploading data downloaded for this file", - "allow upload", - True, - "Allow" - ), ] return options diff --git a/lbrynet/lbryfilemanager/EncryptedFileDownloader.py b/lbrynet/lbryfilemanager/EncryptedFileDownloader.py index b257f4994..356cb02df 100644 --- a/lbrynet/lbryfilemanager/EncryptedFileDownloader.py +++ b/lbrynet/lbryfilemanager/EncryptedFileDownloader.py @@ -149,8 +149,10 @@ class ManagedEncryptedFileDownloaderFactory(object): return True @defer.inlineCallbacks - def make_downloader(self, metadata, data_rate, payment_rate_manager, download_directory=None, + def make_downloader(self, metadata, options, payment_rate_manager, download_directory=None, file_name=None): + assert len(options) == 1 + data_rate = options[0] stream_hash = yield save_sd_info(self.lbry_file_manager.stream_info_manager, metadata.validator.raw_info) if metadata.metadata_source == StreamMetadata.FROM_BLOB: diff --git a/lbrynet/lbryfilemanager/EncryptedFileManager.py b/lbrynet/lbryfilemanager/EncryptedFileManager.py index d00862b10..89900f01d 100644 --- a/lbrynet/lbryfilemanager/EncryptedFileManager.py +++ b/lbrynet/lbryfilemanager/EncryptedFileManager.py @@ -269,9 +269,9 @@ class EncryptedFileManager(object): @rerun_if_locked def _save_lbry_file(self, stream_hash, data_payment_rate): def do_save(db_transaction): - db_transaction.execute("insert into lbry_file_options values (?, ?, ?)", - (data_payment_rate, ManagedEncryptedFileDownloader.STATUS_STOPPED, - stream_hash)) + row = (data_payment_rate, ManagedEncryptedFileDownloader.STATUS_STOPPED, stream_hash) + log.debug('Saving %s to db', row) + db_transaction.execute("insert into lbry_file_options values (?, ?, ?)", row) return db_transaction.lastrowid return self.sql_db.runInteraction(do_save) diff --git a/lbrynet/lbrylive/client/LiveStreamDownloader.py b/lbrynet/lbrylive/client/LiveStreamDownloader.py index 4b152f22a..913aba7dc 100644 --- a/lbrynet/lbrylive/client/LiveStreamDownloader.py +++ b/lbrynet/lbrylive/client/LiveStreamDownloader.py @@ -141,7 +141,7 @@ class FullLiveStreamDownloaderFactory(object): def can_download(self, sd_validator): return True - def make_downloader(self, metadata, data_rate, payment_rate_manager): + def make_downloader(self, metadata, options, payment_rate_manager): # TODO: check options for payment rate manager parameters prm = LiveStreamPaymentRateManager(self.default_payment_rate_manager, payment_rate_manager) diff --git a/lbrynet/lbrynet_daemon/Daemon.py b/lbrynet/lbrynet_daemon/Daemon.py index d3224cda4..c184cb3d4 100644 --- a/lbrynet/lbrynet_daemon/Daemon.py +++ b/lbrynet/lbrynet_daemon/Daemon.py @@ -176,7 +176,7 @@ class AlwaysSend(object): @defer.inlineCallbacks def calculate_available_blob_size(blob_manager): blob_hashes = yield blob_manager.get_all_verified_blobs() - blobs = yield defer.DeferredList([blob_manager.get_blob(b, True) for b in blob_hashes]) + blobs = yield defer.DeferredList([blob_manager.get_blob(b) for b in blob_hashes]) defer.returnValue(sum(b.length for success, b in blobs if success and b.length)) diff --git a/lbrynet/lbrynet_daemon/Downloader.py b/lbrynet/lbrynet_daemon/Downloader.py index 0db02ee44..9202c22f9 100644 --- a/lbrynet/lbrynet_daemon/Downloader.py +++ b/lbrynet/lbrynet_daemon/Downloader.py @@ -119,9 +119,11 @@ class GetStream(object): @defer.inlineCallbacks def get_downloader(self, factory, stream_metadata): + # TODO: we should use stream_metadata.options.get_downloader_options + # instead of hard-coding the options to be [self.data_rate] downloader = yield factory.make_downloader( stream_metadata, - self.data_rate, + [self.data_rate], self.payment_rate_manager, download_directory=self.download_directory, file_name=self.file_name diff --git a/lbrynet/reflector/client/client.py b/lbrynet/reflector/client/client.py index b67ca1b1a..eb39e6bc4 100644 --- a/lbrynet/reflector/client/client.py +++ b/lbrynet/reflector/client/client.py @@ -113,7 +113,7 @@ class EncryptedFileReflectorClient(Protocol): def get_blobs(blobs): for (blob, _, _, blob_len) in blobs: if blob: - yield self.blob_manager.get_blob(blob, True, blob_len) + yield self.blob_manager.get_blob(blob, blob_len) dl = defer.DeferredList(list(get_blobs(blobs_in_stream)), consumeErrors=True) dl.addCallback(lambda blobs: [blob for r, blob in blobs if r and blob.is_validated()]) @@ -155,7 +155,7 @@ class EncryptedFileReflectorClient(Protocol): self.stream_descriptor = sd_blob d = self.factory.stream_info_manager.get_sd_blob_hashes_for_stream(self.factory.stream_hash) - d.addCallback(lambda sd: self.factory.blob_manager.get_blob(sd[0], True)) + d.addCallback(lambda sd: self.factory.blob_manager.get_blob(sd[0])) d.addCallback(_save_descriptor_blob) return d diff --git a/lbrynet/reflector/server/server.py b/lbrynet/reflector/server/server.py index 83f04f864..86e143fd5 100644 --- a/lbrynet/reflector/server/server.py +++ b/lbrynet/reflector/server/server.py @@ -222,7 +222,7 @@ class ReflectorServer(Protocol): sd_blob_size = request_dict[SD_BLOB_SIZE] if self.blob_write is None: - d = self.blob_manager.get_blob(sd_blob_hash, True, sd_blob_size) + d = self.blob_manager.get_blob(sd_blob_hash, sd_blob_size) d.addCallback(self.get_descriptor_response) d.addCallback(self.send_response) else: @@ -266,7 +266,7 @@ class ReflectorServer(Protocol): for blob in sd_blob['blobs']: if 'blob_hash' in blob and 'length' in blob: blob_hash, blob_len = blob['blob_hash'], blob['length'] - d = self.blob_manager.get_blob(blob_hash, True, blob_len) + d = self.blob_manager.get_blob(blob_hash, blob_len) d.addCallback(lambda blob: blob_hash if not blob.is_validated() else None) yield d diff --git a/tests/functional/test_misc.py b/tests/functional/test_misc.py index 1b028ae38..fef270b03 100644 --- a/tests/functional/test_misc.py +++ b/tests/functional/test_misc.py @@ -737,7 +737,7 @@ class TestTransfer(TestCase): factories = metadata.factories chosen_options = [ o.default_value for o in options.get_downloader_options(info_validator, prm)] - return factories[0].make_downloader(metadata, chosen_options, prm) + return factories[0].make_downloader(metadata, choosen_options, prm) def start_lbry_file(lbry_file): lbry_file = lbry_file diff --git a/tests/functional/test_reflector.py b/tests/functional/test_reflector.py index 7067d9776..2ed14f214 100644 --- a/tests/functional/test_reflector.py +++ b/tests/functional/test_reflector.py @@ -165,7 +165,7 @@ class TestReflector(unittest.TestCase): return defer.DeferredList(check_blob_ds) def verify_have_blob(blob_hash, blob_size): - d = self.server_blob_manager.get_blob(blob_hash, True) + d = self.server_blob_manager.get_blob(blob_hash) d.addCallback(lambda blob: verify_blob_completed(blob, blob_size)) return d @@ -196,7 +196,7 @@ class TestReflector(unittest.TestCase): return defer.DeferredList(check_blob_ds) def verify_have_blob(blob_hash, blob_size): - d = self.server_blob_manager.get_blob(blob_hash, True) + d = self.server_blob_manager.get_blob(blob_hash) d.addCallback(lambda blob: verify_blob_completed(blob, blob_size)) return d @@ -226,7 +226,7 @@ class TestReflector(unittest.TestCase): return defer.DeferredList(check_blob_ds) def verify_have_blob(blob_hash, blob_size): - d = self.server_blob_manager.get_blob(blob_hash, True) + d = self.server_blob_manager.get_blob(blob_hash) d.addCallback(lambda blob: verify_blob_completed(blob, blob_size)) return d