diff --git a/LICENSES/CLA-signed-list.md b/LICENSES/CLA-signed-list.md index 4ea70fd0..4c36d6bf 100644 --- a/LICENSES/CLA-signed-list.md +++ b/LICENSES/CLA-signed-list.md @@ -19,3 +19,4 @@ C/ My company has custom contribution contract with Lutra Consulting Ltd. or I a * lavor, 26th April 2023 * luxusko, 25th August 2023 * jozef-budac, 30th January 2024 +* fernandinand, 13th March 2025 \ No newline at end of file diff --git a/server/mergin/app.py b/server/mergin/app.py index 0f23e2ac..654d5c04 100644 --- a/server/mergin/app.py +++ b/server/mergin/app.py @@ -29,7 +29,7 @@ from .sync.utils import get_blacklisted_dirs, get_blacklisted_files from .config import Configuration -from .commands import add_commands +from .commands import add_commands as server_commands convention = { "ix": "ix_%(column_0_label)s", @@ -139,8 +139,6 @@ def create_simple_app() -> Flask: if Configuration.GEVENT_WORKER: flask_app.wsgi_app = GeventTimeoutMiddleware(flask_app.wsgi_app) - add_commands(flask_app) - return flask_app @@ -189,6 +187,7 @@ def create_app(public_keys: List[str] = None) -> Flask: login_manager.init_app(app.app) # register auth blueprint register_auth(app.app) + server_commands(app.app) # adjust login manager @login_manager.user_loader diff --git a/server/mergin/commands.py b/server/mergin/commands.py index 3b2b16d4..eef371fa 100644 --- a/server/mergin/commands.py +++ b/server/mergin/commands.py @@ -2,6 +2,7 @@ from flask import Flask import random import string +import os from datetime import datetime, timezone @@ -82,6 +83,16 @@ def _send_email(email: str): f"Error sending email: {e}", ) + def _check_permissions(path): + """Check for write permission on working folders""" + + if not os.access(path, os.W_OK): + _echo_error( + f"Permissions for {path} folder not set correctly. Please review these settings.", + ) + else: + click.secho(f"Permissions granted for {path} folder", fg="green") + def _check_server(): # pylint: disable=W0612 """Check server configuration.""" @@ -117,6 +128,8 @@ def _check_server(): # pylint: disable=W0612 else: click.secho("Database initialized properly", fg="green") + _check_permissions(app.config.get("LOCAL_PROJECTS")) + _check_celery() def _init_db(): @@ -209,3 +222,9 @@ def send_check_email(email: str): # pylint: disable=W0612 def check(): """Check server configuration.""" _check_server() + + @server.command() + @click.option("--path", required=False, default=app.config.get("LOCAL_PROJECTS")) + def permissions(path: str): + """Check for specific path write permission""" + _check_permissions(path)