verify streams only after migration
This commit is contained in:
parent
b3bf193188
commit
df735252e5
2 changed files with 14 additions and 12 deletions
|
@ -244,7 +244,7 @@ class Daemon(AuthJSONRPCServer):
|
||||||
yield self._start_analytics()
|
yield self._start_analytics()
|
||||||
yield add_lbry_file_to_sd_identifier(self.sd_identifier)
|
yield add_lbry_file_to_sd_identifier(self.sd_identifier)
|
||||||
yield self._setup_stream_identifier()
|
yield self._setup_stream_identifier()
|
||||||
yield self._setup_lbry_file_manager()
|
yield self._setup_lbry_file_manager(verify_streams=migrated)
|
||||||
yield self._setup_query_handlers()
|
yield self._setup_query_handlers()
|
||||||
yield self._setup_server()
|
yield self._setup_server()
|
||||||
log.info("Starting balance: " + str(self.session.wallet.get_balance()))
|
log.info("Starting balance: " + str(self.session.wallet.get_balance()))
|
||||||
|
@ -512,11 +512,11 @@ class Daemon(AuthJSONRPCServer):
|
||||||
defer.returnValue(migrated)
|
defer.returnValue(migrated)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def _setup_lbry_file_manager(self):
|
def _setup_lbry_file_manager(self, verify_streams):
|
||||||
log.info('Starting the file manager')
|
log.info('Starting the file manager')
|
||||||
self.startup_status = STARTUP_STAGES[3]
|
self.startup_status = STARTUP_STAGES[3]
|
||||||
self.lbry_file_manager = EncryptedFileManager(self.session, self.sd_identifier)
|
self.lbry_file_manager = EncryptedFileManager(self.session, self.sd_identifier)
|
||||||
yield self.lbry_file_manager.setup()
|
yield self.lbry_file_manager.setup(verify_streams)
|
||||||
log.info('Done setting up file manager')
|
log.info('Done setting up file manager')
|
||||||
|
|
||||||
def _start_analytics(self):
|
def _start_analytics(self):
|
||||||
|
|
|
@ -42,9 +42,9 @@ class EncryptedFileManager(object):
|
||||||
self.lbry_file_reflector = task.LoopingCall(self.reflect_lbry_files)
|
self.lbry_file_reflector = task.LoopingCall(self.reflect_lbry_files)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def setup(self):
|
def setup(self, verify_streams=False):
|
||||||
yield self._add_to_sd_identifier()
|
yield self._add_to_sd_identifier()
|
||||||
yield self._start_lbry_files()
|
yield self._start_lbry_files(verify_streams)
|
||||||
log.info("Started file manager")
|
log.info("Started file manager")
|
||||||
|
|
||||||
def get_lbry_file_status(self, lbry_file):
|
def get_lbry_file_status(self, lbry_file):
|
||||||
|
@ -97,7 +97,7 @@ class EncryptedFileManager(object):
|
||||||
)
|
)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def _start_lbry_file(self, file_info, payment_rate_manager):
|
def _start_lbry_file(self, file_info, payment_rate_manager, verify_stream):
|
||||||
lbry_file = self._get_lbry_file(
|
lbry_file = self._get_lbry_file(
|
||||||
file_info['row_id'], file_info['stream_hash'], payment_rate_manager, file_info['sd_hash'],
|
file_info['row_id'], file_info['stream_hash'], payment_rate_manager, file_info['sd_hash'],
|
||||||
file_info['key'], file_info['stream_name'], file_info['file_name'], file_info['download_directory'],
|
file_info['key'], file_info['stream_name'], file_info['file_name'], file_info['download_directory'],
|
||||||
|
@ -105,10 +105,12 @@ class EncryptedFileManager(object):
|
||||||
)
|
)
|
||||||
yield lbry_file.get_claim_info()
|
yield lbry_file.get_claim_info()
|
||||||
try:
|
try:
|
||||||
# verify the stream is valid (we might have downloaded an invalid stream
|
# verify if the stream is valid (we might have downloaded an invalid stream
|
||||||
# in the past when the validation check didn't work)
|
# in the past when the validation check didn't work. This runs after every
|
||||||
stream_info = yield get_sd_info(self.storage, file_info['stream_hash'], include_blobs=True)
|
# migration to ensure blobs migrated from that past version gets verified)
|
||||||
validate_descriptor(stream_info)
|
if verify_stream:
|
||||||
|
stream_info = yield get_sd_info(self.storage, file_info['stream_hash'], include_blobs=True)
|
||||||
|
validate_descriptor(stream_info)
|
||||||
except InvalidStreamDescriptorError as err:
|
except InvalidStreamDescriptorError as err:
|
||||||
log.warning("Stream for descriptor %s is invalid (%s), cleaning it up",
|
log.warning("Stream for descriptor %s is invalid (%s), cleaning it up",
|
||||||
lbry_file.sd_hash, err.message)
|
lbry_file.sd_hash, err.message)
|
||||||
|
@ -126,7 +128,7 @@ class EncryptedFileManager(object):
|
||||||
log.warning("Failed to start %i", file_info.get('rowid'))
|
log.warning("Failed to start %i", file_info.get('rowid'))
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def _start_lbry_files(self):
|
def _start_lbry_files(self, verify_streams):
|
||||||
files = yield self.session.storage.get_all_lbry_files()
|
files = yield self.session.storage.get_all_lbry_files()
|
||||||
b_prm = self.session.base_payment_rate_manager
|
b_prm = self.session.base_payment_rate_manager
|
||||||
payment_rate_manager = NegotiatedPaymentRateManager(b_prm, self.session.blob_tracker)
|
payment_rate_manager = NegotiatedPaymentRateManager(b_prm, self.session.blob_tracker)
|
||||||
|
@ -134,7 +136,7 @@ class EncryptedFileManager(object):
|
||||||
log.info("Starting %i files", len(files))
|
log.info("Starting %i files", len(files))
|
||||||
dl = []
|
dl = []
|
||||||
for file_info in files:
|
for file_info in files:
|
||||||
dl.append(self._start_lbry_file(file_info, payment_rate_manager))
|
dl.append(self._start_lbry_file(file_info, payment_rate_manager, verify_streams))
|
||||||
|
|
||||||
yield defer.DeferredList(dl)
|
yield defer.DeferredList(dl)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue