remove more upload_allowed arguments

This commit is contained in:
jobevers 2017-02-14 13:18:42 -06:00
parent 4fb5e932e6
commit 9e2cda0cdc
12 changed files with 25 additions and 30 deletions

View file

@ -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)

View file

@ -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):

View file

@ -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

View file

@ -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:

View file

@ -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)

View file

@ -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)

View file

@ -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))

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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