remove ManagedEncryptedFileDownloader.load_file_attributes() move it to EncryptedFileDownloader.set_stream_info()
This commit is contained in:
parent
b859f7a23f
commit
57117baab5
3 changed files with 20 additions and 32 deletions
|
@ -35,9 +35,9 @@ class Publisher(object):
|
||||||
stream_hash = yield create_lbry_file(self.session, self.lbry_file_manager, file_name,
|
stream_hash = yield create_lbry_file(self.session, self.lbry_file_manager, file_name,
|
||||||
read_handle)
|
read_handle)
|
||||||
prm = self.session.payment_rate_manager
|
prm = self.session.payment_rate_manager
|
||||||
self.lbry_file = yield self.lbry_file_manager.add_lbry_file(stream_hash, prm)
|
|
||||||
sd_hash = yield publish_sd_blob(self.lbry_file_manager.stream_info_manager,
|
sd_hash = yield publish_sd_blob(self.lbry_file_manager.stream_info_manager,
|
||||||
self.session.blob_manager, self.lbry_file.stream_hash)
|
self.session.blob_manager, stream_hash)
|
||||||
|
self.lbry_file = yield self.lbry_file_manager.add_lbry_file(stream_hash, prm)
|
||||||
if 'source' not in claim_dict['stream']:
|
if 'source' not in claim_dict['stream']:
|
||||||
claim_dict['stream']['source'] = {}
|
claim_dict['stream']['source'] = {}
|
||||||
claim_dict['stream']['source']['source'] = sd_hash
|
claim_dict['stream']['source']['source'] = sd_hash
|
||||||
|
@ -47,7 +47,6 @@ class Publisher(object):
|
||||||
|
|
||||||
claim_out = yield self.make_claim(name, bid, claim_dict, claim_address, change_address)
|
claim_out = yield self.make_claim(name, bid, claim_dict, claim_address, change_address)
|
||||||
self.lbry_file.completed = True
|
self.lbry_file.completed = True
|
||||||
yield self.lbry_file.load_file_attributes(sd_hash)
|
|
||||||
yield self.lbry_file.save_status()
|
yield self.lbry_file.save_status()
|
||||||
defer.returnValue(claim_out)
|
defer.returnValue(claim_out)
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@ from zope.interface import implements
|
||||||
from twisted.internet import defer
|
from twisted.internet import defer
|
||||||
|
|
||||||
from lbrynet.core.client.StreamProgressManager import FullStreamProgressManager
|
from lbrynet.core.client.StreamProgressManager import FullStreamProgressManager
|
||||||
from lbrynet.core.Error import NoSuchStreamHash
|
|
||||||
from lbrynet.core.utils import short_hash
|
from lbrynet.core.utils import short_hash
|
||||||
from lbrynet.core.StreamDescriptor import StreamMetadata
|
from lbrynet.core.StreamDescriptor import StreamMetadata
|
||||||
from lbrynet.lbry_file.client.EncryptedFileDownloader import EncryptedFileSaver
|
from lbrynet.lbry_file.client.EncryptedFileDownloader import EncryptedFileSaver
|
||||||
|
@ -35,18 +34,21 @@ class ManagedEncryptedFileDownloader(EncryptedFileSaver):
|
||||||
STATUS_RUNNING = "running"
|
STATUS_RUNNING = "running"
|
||||||
STATUS_STOPPED = "stopped"
|
STATUS_STOPPED = "stopped"
|
||||||
STATUS_FINISHED = "finished"
|
STATUS_FINISHED = "finished"
|
||||||
|
"""
|
||||||
|
These are started by EncryptedFileManager, aka, file_manager
|
||||||
|
"""
|
||||||
def __init__(self, rowid, stream_hash, peer_finder, rate_limiter,
|
def __init__(self, rowid, stream_hash, peer_finder, rate_limiter,
|
||||||
blob_manager, stream_info_manager, lbry_file_manager,
|
blob_manager, stream_info_manager, lbry_file_manager,
|
||||||
payment_rate_manager, wallet, download_directory,
|
payment_rate_manager, wallet, download_directory,
|
||||||
file_name=None):
|
file_name=None):
|
||||||
|
|
||||||
EncryptedFileSaver.__init__(self, stream_hash, peer_finder,
|
EncryptedFileSaver.__init__(self, stream_hash, peer_finder,
|
||||||
rate_limiter, blob_manager,
|
rate_limiter, blob_manager,
|
||||||
stream_info_manager,
|
stream_info_manager,
|
||||||
payment_rate_manager, wallet,
|
payment_rate_manager, wallet,
|
||||||
download_directory,
|
download_directory,
|
||||||
file_name)
|
file_name)
|
||||||
self.sd_hash = None
|
|
||||||
self.rowid = rowid
|
self.rowid = rowid
|
||||||
self.lbry_file_manager = lbry_file_manager
|
self.lbry_file_manager = lbry_file_manager
|
||||||
self._saving_status = False
|
self._saving_status = False
|
||||||
|
@ -57,7 +59,6 @@ class ManagedEncryptedFileDownloader(EncryptedFileSaver):
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def restore(self):
|
def restore(self):
|
||||||
yield self.load_file_attributes()
|
|
||||||
|
|
||||||
status = yield self.lbry_file_manager.get_lbry_file_status(self)
|
status = yield self.lbry_file_manager.get_lbry_file_status(self)
|
||||||
log_status(self.file_name, self.sd_hash, status)
|
log_status(self.file_name, self.sd_hash, status)
|
||||||
|
@ -101,23 +102,9 @@ class ManagedEncryptedFileDownloader(EncryptedFileSaver):
|
||||||
defer.returnValue(EncryptedFileStatusReport(self.file_name, num_blobs_completed,
|
defer.returnValue(EncryptedFileStatusReport(self.file_name, num_blobs_completed,
|
||||||
num_blobs_known, status))
|
num_blobs_known, status))
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
|
||||||
def load_file_attributes(self, sd_hash=None):
|
|
||||||
if not sd_hash:
|
|
||||||
sd_hash = yield self.stream_info_manager.get_sd_blob_hashes_for_stream(self.stream_hash)
|
|
||||||
if sd_hash:
|
|
||||||
self.sd_hash = sd_hash[0]
|
|
||||||
else:
|
|
||||||
raise NoSuchStreamHash(self.stream_hash)
|
|
||||||
else:
|
|
||||||
self.sd_hash = sd_hash
|
|
||||||
|
|
||||||
defer.returnValue(None)
|
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def _start(self):
|
def _start(self):
|
||||||
yield EncryptedFileSaver._start(self)
|
yield EncryptedFileSaver._start(self)
|
||||||
yield self.load_file_attributes()
|
|
||||||
status = yield self._save_status()
|
status = yield self._save_status()
|
||||||
log_status(self.file_name, self.sd_hash, status)
|
log_status(self.file_name, self.sd_hash, status)
|
||||||
defer.returnValue(status)
|
defer.returnValue(status)
|
||||||
|
|
|
@ -6,6 +6,7 @@ from lbrynet.lbry_file.StreamDescriptor import save_sd_info
|
||||||
from lbrynet.cryptstream.client.CryptStreamDownloader import CryptStreamDownloader
|
from lbrynet.cryptstream.client.CryptStreamDownloader import CryptStreamDownloader
|
||||||
from lbrynet.core.client.StreamProgressManager import FullStreamProgressManager
|
from lbrynet.core.client.StreamProgressManager import FullStreamProgressManager
|
||||||
from lbrynet.core.StreamDescriptor import StreamMetadata
|
from lbrynet.core.StreamDescriptor import StreamMetadata
|
||||||
|
from lbrynet.core.Error import NoSuchStreamHash
|
||||||
from lbrynet.interfaces import IStreamDownloaderFactory
|
from lbrynet.interfaces import IStreamDownloaderFactory
|
||||||
from lbrynet.lbry_file.client.EncryptedFileMetadataHandler import EncryptedFileMetadataHandler
|
from lbrynet.lbry_file.client.EncryptedFileMetadataHandler import EncryptedFileMetadataHandler
|
||||||
import os
|
import os
|
||||||
|
@ -28,21 +29,22 @@ class EncryptedFileDownloader(CryptStreamDownloader):
|
||||||
self.stream_info_manager = stream_info_manager
|
self.stream_info_manager = stream_info_manager
|
||||||
self.suggested_file_name = None
|
self.suggested_file_name = None
|
||||||
self._calculated_total_bytes = None
|
self._calculated_total_bytes = None
|
||||||
|
self.sd_hash = None
|
||||||
|
|
||||||
|
@defer.inlineCallbacks
|
||||||
def set_stream_info(self):
|
def set_stream_info(self):
|
||||||
if self.key is None:
|
if self.key is None:
|
||||||
d = self.stream_info_manager.get_stream_info(self.stream_hash)
|
out = yield self.stream_info_manager.get_stream_info(self.stream_hash)
|
||||||
|
key, stream_name, suggested_file_name = out
|
||||||
def set_stream_info(stream_info):
|
|
||||||
key, stream_name, suggested_file_name = stream_info
|
|
||||||
self.key = binascii.unhexlify(key)
|
self.key = binascii.unhexlify(key)
|
||||||
self.stream_name = binascii.unhexlify(stream_name)
|
self.stream_name = binascii.unhexlify(stream_name)
|
||||||
self.suggested_file_name = binascii.unhexlify(suggested_file_name)
|
self.suggested_file_name = binascii.unhexlify(suggested_file_name)
|
||||||
|
|
||||||
d.addCallback(set_stream_info)
|
out = yield self.stream_info_manager.get_sd_blob_hashes_for_stream(self.stream_hash)
|
||||||
return d
|
if out:
|
||||||
|
self.sd_hash = out[0]
|
||||||
else:
|
else:
|
||||||
return defer.succeed(True)
|
raise NoSuchStreamHash(self.stream_hash)
|
||||||
|
|
||||||
def delete_data(self):
|
def delete_data(self):
|
||||||
d1 = self.stream_info_manager.get_blobs_for_stream(self.stream_hash)
|
d1 = self.stream_info_manager.get_blobs_for_stream(self.stream_hash)
|
||||||
|
|
Loading…
Reference in a new issue