Merge branch 'conf_reflect_options'
This commit is contained in:
commit
0bdcab1166
4 changed files with 16 additions and 13 deletions
|
@ -29,7 +29,7 @@ at anytime.
|
||||||
*
|
*
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
*
|
* Added configuration options for auto re-reflect
|
||||||
*
|
*
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
|
|
|
@ -250,7 +250,12 @@ ADJUSTABLE_SETTINGS = {
|
||||||
'peer_port': (int, 3333),
|
'peer_port': (int, 3333),
|
||||||
'pointtrader_server': (str, 'http://127.0.0.1:2424'),
|
'pointtrader_server': (str, 'http://127.0.0.1:2424'),
|
||||||
'reflector_port': (int, 5566),
|
'reflector_port': (int, 5566),
|
||||||
|
# if reflect_uploads is True, reflect files on publish
|
||||||
'reflect_uploads': (bool, True),
|
'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),
|
'reflector_servers': (list, [('reflector.lbry.io', 5566)], server_port),
|
||||||
'run_reflector_server': (bool, False),
|
'run_reflector_server': (bool, False),
|
||||||
'sd_download_timeout': (int, 3),
|
'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 AlreadyStoppedError
|
||||||
from lbrynet.cryptstream.client.CryptStreamDownloader import CurrentlyStoppingError
|
from lbrynet.cryptstream.client.CryptStreamDownloader import CurrentlyStoppingError
|
||||||
from lbrynet.core.sqlite_helpers import rerun_if_locked
|
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
|
from lbrynet import conf
|
||||||
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
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):
|
class EncryptedFileManager(object):
|
||||||
"""Keeps track of currently opened LBRY Files, their options, and
|
"""Keeps track of currently opened LBRY Files, their options, and
|
||||||
their LBRY File specific metadata.
|
their LBRY File specific metadata.
|
||||||
|
@ -40,6 +31,9 @@ class EncryptedFileManager(object):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, session, stream_info_manager, sd_identifier, download_directory=None):
|
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.session = session
|
||||||
self.stream_info_manager = stream_info_manager
|
self.stream_info_manager = stream_info_manager
|
||||||
# TODO: why is sd_identifier part of the file manager?
|
# TODO: why is sd_identifier part of the file manager?
|
||||||
|
@ -58,8 +52,8 @@ class EncryptedFileManager(object):
|
||||||
yield self._open_db()
|
yield self._open_db()
|
||||||
yield self._add_to_sd_identifier()
|
yield self._add_to_sd_identifier()
|
||||||
yield self._start_lbry_files()
|
yield self._start_lbry_files()
|
||||||
if conf.settings['reflect_uploads']:
|
if self.auto_re_reflect is True:
|
||||||
safe_start_looping_call(self.lbry_file_reflector)
|
safe_start_looping_call(self.lbry_file_reflector, self.auto_re_reflect_interval)
|
||||||
|
|
||||||
def get_lbry_file_status(self, lbry_file):
|
def get_lbry_file_status(self, lbry_file):
|
||||||
return self._get_lbry_file_status(lbry_file.rowid)
|
return self._get_lbry_file_status(lbry_file.rowid)
|
||||||
|
|
|
@ -1,11 +1,15 @@
|
||||||
from twisted.internet import defer
|
from twisted.internet import defer
|
||||||
from twisted.trial import unittest
|
from twisted.trial import unittest
|
||||||
|
from lbrynet import conf
|
||||||
from lbrynet.file_manager.EncryptedFileDownloader import ManagedEncryptedFileDownloader
|
from lbrynet.file_manager.EncryptedFileDownloader import ManagedEncryptedFileDownloader
|
||||||
from lbrynet.file_manager.EncryptedFileManager import EncryptedFileManager
|
from lbrynet.file_manager.EncryptedFileManager import EncryptedFileManager
|
||||||
from tests.util import random_lbry_hash
|
from tests.util import random_lbry_hash
|
||||||
|
|
||||||
class TestEncryptedFileManager(unittest.TestCase):
|
class TestEncryptedFileManager(unittest.TestCase):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
conf.initialize_settings()
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def test_database_operations(self):
|
def test_database_operations(self):
|
||||||
# test database read/write functions in EncrypteFileManager
|
# test database read/write functions in EncrypteFileManager
|
||||||
|
|
Loading…
Reference in a new issue