file_manager: allow directories in "/etc/moonraker" to be registered

This may be useful for system packaging options that do not wish to put configuration in the home directory.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Arksine
2020-12-20 08:37:45 -05:00
parent 684ff07ba2
commit 9a309ffd59
3 changed files with 18 additions and 11 deletions

View File

@@ -15,6 +15,7 @@ from tornado.locks import Event
VALID_GCODE_EXTS = ['.gcode', '.g', '.gco']
FULL_ACCESS_ROOTS = ["gcodes", "config"]
ETC_DIR = "/etc/moonraker"
METADATA_SCRIPT = os.path.normpath(os.path.join(
os.path.dirname(__file__), "../../scripts/extract_metadata.py"))
@@ -85,8 +86,8 @@ class FileManager:
return False
home = os.path.expanduser('~')
path = os.path.normpath(os.path.expanduser(path))
if not os.path.isdir(path) or not path.startswith(home) or \
path == home:
if not os.path.isdir(path) or path == home or \
not (path.startswith(home) or path.startswith(ETC_DIR)):
logging.info(
f"\nSupplied path ({path}) for ({root}) not valid. Please\n"
"check that the path exists and is a subfolder in the HOME\n"