Skip to content
1 change: 1 addition & 0 deletions LICENSES/CLA-signed-list.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 2 additions & 3 deletions server/mergin/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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


Expand Down Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions server/mergin/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from flask import Flask
import random
import string
import os
from datetime import datetime, timezone


Expand Down Expand Up @@ -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."""

Expand Down Expand Up @@ -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():
Expand Down Expand Up @@ -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)
Loading