forked from LBRYCommunity/lbry-sdk
add ability to control re-reflects through config
This commit is contained in:
parent
2aee5f7948
commit
9d92fba02e
3 changed files with 15 additions and 12 deletions
|
@ -250,7 +250,12 @@ ADJUSTABLE_SETTINGS = {
|
|||
'peer_port': (int, 3333),
|
||||
'pointtrader_server': (str, 'http://127.0.0.1:2424'),
|
||||
'reflector_port': (int, 5566),
|
||||
# if reflect_uploads is True, reflect files on publish
|
||||
'reflect_uploads': (bool, True),
|
||||
# if auto_re_reflect is True, attempt to re-reflect files on startup and
|
||||
# at every auto_re_reflect_interval seconds, useful if initial reflect is unreliable
|
||||
'auto_re_reflect': (bool, True),
|
||||
'auto_re_reflect_interval': (int, 3600),
|
||||
'reflector_servers': (list, [('reflector.lbry.io', 5566)], server_port),
|
||||
'run_reflector_server': (bool, False),
|
||||
'sd_download_timeout': (int, 3),
|
||||
|
|
|
@ -17,22 +17,13 @@ from lbrynet.lbry_file.StreamDescriptor import EncryptedFileStreamType
|
|||
from lbrynet.cryptstream.client.CryptStreamDownloader import AlreadyStoppedError
|
||||
from lbrynet.cryptstream.client.CryptStreamDownloader import CurrentlyStoppingError
|
||||
from lbrynet.core.sqlite_helpers import rerun_if_locked
|
||||
from lbrynet.core.utils import safe_start_looping_call, safe_stop_looping_call
|
||||
from lbrynet import conf
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def safe_start_looping_call(looping_call, seconds=3600):
|
||||
if not looping_call.running:
|
||||
looping_call.start(seconds)
|
||||
|
||||
|
||||
def safe_stop_looping_call(looping_call):
|
||||
if looping_call.running:
|
||||
looping_call.stop()
|
||||
|
||||
|
||||
class EncryptedFileManager(object):
|
||||
"""Keeps track of currently opened LBRY Files, their options, and
|
||||
their LBRY File specific metadata.
|
||||
|
@ -40,6 +31,9 @@ class EncryptedFileManager(object):
|
|||
"""
|
||||
|
||||
def __init__(self, session, stream_info_manager, sd_identifier, download_directory=None):
|
||||
|
||||
self.auto_re_reflect = conf.settings['auto_re_reflect']
|
||||
self.auto_re_reflect_interval = conf.settings['auto_re_reflect_interval']
|
||||
self.session = session
|
||||
self.stream_info_manager = stream_info_manager
|
||||
# TODO: why is sd_identifier part of the file manager?
|
||||
|
@ -58,8 +52,8 @@ class EncryptedFileManager(object):
|
|||
yield self._open_db()
|
||||
yield self._add_to_sd_identifier()
|
||||
yield self._start_lbry_files()
|
||||
if conf.settings['reflect_uploads']:
|
||||
safe_start_looping_call(self.lbry_file_reflector)
|
||||
if self.auto_re_reflect is True:
|
||||
safe_start_looping_call(self.lbry_file_reflector, self.auto_re_reflect_interval)
|
||||
|
||||
def get_lbry_file_status(self, lbry_file):
|
||||
return self._get_lbry_file_status(lbry_file.rowid)
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
from twisted.internet import defer
|
||||
from twisted.trial import unittest
|
||||
from lbrynet import conf
|
||||
from lbrynet.file_manager.EncryptedFileDownloader import ManagedEncryptedFileDownloader
|
||||
from lbrynet.file_manager.EncryptedFileManager import EncryptedFileManager
|
||||
from tests.util import random_lbry_hash
|
||||
|
||||
class TestEncryptedFileManager(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
conf.initialize_settings()
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def test_database_operations(self):
|
||||
# test database read/write functions in EncrypteFileManager
|
||||
|
|
Loading…
Reference in a new issue