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:
parent
acc08693b3
commit
153ab41ce7
@ -15,10 +15,9 @@ from .__pkginfo__ import VERSION
|
|||||||
# DIRECRORY_CONFIG, DIRECRORY_STATE, DIRECTORY_LOGS and DIRECTORY_CACHE
|
# DIRECRORY_CONFIG, DIRECRORY_STATE, DIRECTORY_LOGS and DIRECTORY_CACHE
|
||||||
# config can only be determined by environment variable, the others can be loaded
|
# config can only be determined by environment variable, the others can be loaded
|
||||||
# from the config files
|
# from the config files
|
||||||
# explicit settings will always be respected. if there are none:
|
# explicit settings will always be respected, fallback to default
|
||||||
# first check if there is any indication of one of the possibilities being populated already
|
|
||||||
# if not, use the first we have permissions for
|
# if default isn't usable, and config writable, find alternative and fix it in settings
|
||||||
# after we decide which to use, fix it in settings to avoid future heuristics
|
|
||||||
|
|
||||||
# USEFUL FUNCS
|
# USEFUL FUNCS
|
||||||
pthj = os.path.join
|
pthj = os.path.join
|
||||||
@ -205,11 +204,15 @@ malojaconfig = Configuration(
|
|||||||
)
|
)
|
||||||
|
|
||||||
if found_new_config_dir:
|
if found_new_config_dir:
|
||||||
|
try:
|
||||||
malojaconfig["DIRECTORY_CONFIG"] = maloja_dir_config
|
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
|
# this really doesn't matter because when are we gonna load info about where
|
||||||
# the settings file is stored from the settings file
|
# the settings file is stored from the settings file
|
||||||
# but oh well
|
# but oh well
|
||||||
|
|
||||||
|
try:
|
||||||
malojaconfig.render_help(pthj(maloja_dir_config,"settings.md"),
|
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
|
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.
|
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
|
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
|
`/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`).''')
|
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)
|
### STEP 3 - check all possible folders for files (old installation)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if not malojaconfig.readonly:
|
||||||
for datatype in ("state","cache","logs"):
|
for datatype in ("state","cache","logs"):
|
||||||
# obviously default values shouldn't trigger this
|
# obviously default values shouldn't trigger this
|
||||||
# if user has nothing specified, we need to use this
|
# if user has nothing specified, we need to use this
|
||||||
|
Loading…
Reference in New Issue
Block a user