Removing optional_session, passing session down from request middleware. Moving session param to the front of functions.
Some checks failed
CodeQL / Analyze (push) Has been cancelled
Jest Tests / jest-tests (push) Has been cancelled

This commit is contained in:
Roland 2025-12-10 21:16:10 -07:00
parent 1747442db3
commit 344fe9035f
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680
70 changed files with 1035 additions and 1110 deletions

View file

@ -41,7 +41,7 @@ async def import_pbfs(_: Request, body: schema.ImportPost):
@map_bp.get('/files')
@openapi.description('Find any map files, get their import status')
def get_files_status(request: Request):
paths = lib.get_import_status()
paths = lib.get_import_status(request.ctx.session)
paths = sorted(paths, key=lambda i: str(i.path))
pending = request.app.shared_ctx.map_importing.get('pending')
if pending:

View file

@ -11,7 +11,7 @@ from wrolpi.api_utils import api_app
from wrolpi.cmd import SUDO_BIN, run_command
from wrolpi.common import get_media_directory, walk, logger, get_wrolpi_config
from wrolpi.dates import timedelta_to_timestamp, seconds_to_timestamp, now
from wrolpi.db import optional_session, get_db_session
from wrolpi.db import get_db_session
from wrolpi.events import Events
from wrolpi.vars import PROJECT_DIR, IS_RPI5
@ -208,8 +208,7 @@ async def run_import_command(*paths: Path):
raise ValueError(f'Importing map file failed with return code {result.return_code}')
@optional_session
def get_import_status(session: Session = None) -> List[MapFile]:
def get_import_status(session: Session) -> List[MapFile]:
paths = get_map_paths()
map_paths = []
for path in paths: