set ui_version for bundled ui
This commit is contained in:
parent
2afc4c25a2
commit
3bb8f4ac21
3 changed files with 24 additions and 4 deletions
|
@ -252,7 +252,6 @@ class Daemon(AuthJSONRPCServer):
|
|||
self.connection_problem = None
|
||||
self.git_lbrynet_version = None
|
||||
self.git_lbryum_version = None
|
||||
self.ui_version = None
|
||||
self.platform = None
|
||||
self.first_run = None
|
||||
self.log_file = conf.settings.get_log_filename()
|
||||
|
@ -1174,7 +1173,7 @@ class Daemon(AuthJSONRPCServer):
|
|||
'os_system': platform_info['os_system'],
|
||||
'lbrynet_version': lbrynet_version,
|
||||
'lbryum_version': lbryum_version,
|
||||
'ui_version': self.ui_version,
|
||||
'ui_version': platform_info['ui_version'],
|
||||
'remote_lbrynet': self.git_lbrynet_version,
|
||||
'remote_lbryum': self.git_lbryum_version,
|
||||
'lbrynet_update_available': lbrynet_update_available,
|
||||
|
|
|
@ -67,6 +67,10 @@ class UIManager(object):
|
|||
self.check_requirements = (check_requirements if check_requirements is not None
|
||||
else conf.settings.check_ui_requirements)
|
||||
|
||||
# Note that this currently overrides any manual setting of UI.
|
||||
# It might be worth considering changing that behavior but the expectation
|
||||
# is generally that any manual setting of the UI will happen during development
|
||||
# and not for folks checking out the QA / RC builds that bundle the UI.
|
||||
if self._check_for_bundled_ui():
|
||||
return defer.succeed(True)
|
||||
|
||||
|
@ -94,6 +98,7 @@ class UIManager(object):
|
|||
return d
|
||||
|
||||
def _check_for_bundled_ui(self):
|
||||
"""Try to load a bundled UI and return True if successful, False otherwise"""
|
||||
try:
|
||||
bundled_path = get_bundled_ui_path()
|
||||
except Exception:
|
||||
|
@ -101,7 +106,10 @@ class UIManager(object):
|
|||
return False
|
||||
else:
|
||||
bundle_manager = BundledUIManager(self.root, self.active_dir, bundled_path)
|
||||
return bundle_manager.setup()
|
||||
loaded = bundle_manager.setup()
|
||||
if loaded:
|
||||
self.loaded_git_version = bundle_manager.version()
|
||||
return loaded
|
||||
|
||||
def _up_to_date(self):
|
||||
def _get_git_info():
|
||||
|
@ -256,6 +264,12 @@ class BundledUIManager(object):
|
|||
self.active_dir = active_dir
|
||||
self.bundled_ui_path = bundled_ui_path
|
||||
self.data_path = os.path.join(bundled_ui_path, 'data.json')
|
||||
self._version = None
|
||||
|
||||
def version(self):
|
||||
if not self._version:
|
||||
self._version = open_and_read_sha(self.data_path)
|
||||
return self._version
|
||||
|
||||
def bundle_is_available(self):
|
||||
return os.path.exists(self.data_path)
|
||||
|
@ -277,7 +291,8 @@ class BundledUIManager(object):
|
|||
def is_active_already_bundled_ui(self):
|
||||
target_data_path = os.path.join(self.active_dir, 'data.json')
|
||||
if os.path.exists(target_data_path):
|
||||
if are_same_version(self.data_path, target_data_path):
|
||||
target_version = open_and_read_sha(target_data_path)
|
||||
if self.version() == target_version:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
@ -293,6 +308,11 @@ def are_same_version(data_a, data_b):
|
|||
return read_sha(a) == read_sha(b)
|
||||
|
||||
|
||||
def open_and_read_sha(filename):
|
||||
with open(filename) as f:
|
||||
return read_sha(f)
|
||||
|
||||
|
||||
def read_sha(filelike):
|
||||
data = json.load(filelike)
|
||||
return data['sha']
|
||||
|
|
|
@ -39,6 +39,7 @@ class BundledUIManagerTest(unittest.TestCase):
|
|||
touch(os.path.join(self.bundled_dir, 'test.html'))
|
||||
result = self.manager.setup()
|
||||
self.assertTrue(result)
|
||||
self.assertEqual('BARFOO', self.manager.version())
|
||||
expected = ['data.json', 'test.html']
|
||||
self.assertItemsEqual(os.listdir(self.active_dir), expected)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue