mirror of https://gitlab.com/openlp/openlp.git
Merge branch 'fix-duplicate-data-directory' into 'master'
Fix duplicate data directory Closes #1197 See merge request openlp/openlp!528
This commit is contained in:
commit
13afff24fd
|
@ -311,6 +311,18 @@ def set_up_logging(log_path):
|
|||
print(f'Logging to: {file_path} and level {log.level}')
|
||||
|
||||
|
||||
def set_up_web_engine_cache(web_cache_path):
|
||||
"""
|
||||
Setup path for the qt web engine to dump it's files
|
||||
|
||||
:param Path web_cache_path: The folder for the web engine files
|
||||
:rtype: None
|
||||
"""
|
||||
web_engine_profile = QtWebEngineWidgets.QWebEngineProfile.defaultProfile()
|
||||
web_engine_profile.setCachePath(str(web_cache_path))
|
||||
web_engine_profile.setPersistentStoragePath(str(web_cache_path))
|
||||
|
||||
|
||||
def backup_if_version_changed(settings):
|
||||
"""
|
||||
Check version of settings and the application version and backup if the version is different.
|
||||
|
@ -421,6 +433,7 @@ def main():
|
|||
portable_path = resolve(portable_path)
|
||||
data_path = portable_path / 'Data'
|
||||
set_up_logging(portable_path / 'Other')
|
||||
set_up_web_engine_cache(portable_path / 'Other' / 'web_cache')
|
||||
log.info('Running portable')
|
||||
portable_settings_path = data_path / 'OpenLP.ini'
|
||||
# Make this our settings file
|
||||
|
@ -436,6 +449,7 @@ def main():
|
|||
else:
|
||||
application.setApplicationName('OpenLP')
|
||||
set_up_logging(AppLocation.get_directory(AppLocation.CacheDir))
|
||||
set_up_web_engine_cache(portable_path / 'Other' / 'web_cache')
|
||||
# Set the libvlc environment variable if we're frozen
|
||||
if getattr(sys, 'frozen', False) and is_win():
|
||||
# Path to libvlc and the plugins
|
||||
|
|
|
@ -306,7 +306,9 @@ def test_backup_on_upgrade(mocked_question, mocked_get_version, qapp, settings):
|
|||
@patch('openlp.core.app.OpenLP')
|
||||
@patch('openlp.core.app.sys')
|
||||
@patch('openlp.core.app.backup_if_version_changed')
|
||||
def test_main(mock_backup, mock_sys, mock_openlp, app_main_env):
|
||||
@patch('openlp.core.app.set_up_web_engine_cache')
|
||||
@patch('openlp.core.app.set_up_logging')
|
||||
def test_main(mock_logging, mock_web_cache, mock_backup, mock_sys, mock_openlp, app_main_env):
|
||||
"""
|
||||
Test the main method performs primary actions
|
||||
"""
|
||||
|
@ -319,8 +321,10 @@ def test_main(mock_backup, mock_sys, mock_openlp, app_main_env):
|
|||
# WHEN: the main method is run
|
||||
app_main()
|
||||
|
||||
# THEN: Check the application is run and exited
|
||||
# THEN: Check the application is run and exited with logging and web cache path set
|
||||
openlp_instance.run.assert_called_once()
|
||||
mock_logging.assert_called_once()
|
||||
mock_web_cache.assert_called_once()
|
||||
mock_sys.exit.assert_called_once()
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue