1
0
mirror of https://github.com/krateng/maloja.git synced 2023-08-10 21:12:55 +03:00

Improved support for read-only config directory

This commit is contained in:
krateng 2022-04-04 16:18:06 +02:00
parent acc08693b3
commit 153ab41ce7

View File

@ -15,10 +15,9 @@ from .__pkginfo__ import VERSION
# DIRECRORY_CONFIG, DIRECRORY_STATE, DIRECTORY_LOGS and DIRECTORY_CACHE
# config can only be determined by environment variable, the others can be loaded
# from the config files
# explicit settings will always be respected. if there are none:
# first check if there is any indication of one of the possibilities being populated already
# if not, use the first we have permissions for
# after we decide which to use, fix it in settings to avoid future heuristics
# explicit settings will always be respected, fallback to default
# if default isn't usable, and config writable, find alternative and fix it in settings
# USEFUL FUNCS
pthj = os.path.join
@ -205,11 +204,15 @@ malojaconfig = Configuration(
)
if found_new_config_dir:
try:
malojaconfig["DIRECTORY_CONFIG"] = maloja_dir_config
except PermissionError as e:
pass
# this really doesn't matter because when are we gonna load info about where
# the settings file is stored from the settings file
# but oh well
try:
malojaconfig.render_help(pthj(maloja_dir_config,"settings.md"),
top_text='''If you wish to adjust settings in the settings.ini file, do so while the server
is not running in order to avoid data being overwritten.
@ -222,13 +225,15 @@ server via environment variables!
You also can specify additional settings in the files`/run/secrets/maloja.yml` or
`/run/secrets/maloja.ini`, as well as their values directly in files of the respective
name in `/run/secrets/` (e.g. `/run/secrets/lastfm_api_key`).''')
except PermissionError as e:
pass
### STEP 3 - check all possible folders for files (old installation)
if not malojaconfig.readonly:
for datatype in ("state","cache","logs"):
# obviously default values shouldn't trigger this
# if user has nothing specified, we need to use this