Coverage for app/services/upload_layout.py: 100%
8 statements
« prev ^ index » next coverage.py v7.16.2, created at 2026-10-17 15:29 +0000
« prev ^ index » next coverage.py v7.16.2, created at 2026-10-17 15:29 +0000
1"""Names of the folders the app itself writes under UPLOAD_FOLDER, next to
2the documents of the Syncthing-compatible <tenant-slug>/<REG>/<category>/
3layout.
5Both document scanners (the manual reconcile scan and the background
6sync_watcher) walk each tenant folder and treat every file they don't
7already know as a document to import or reconcile — they must skip these.
8"""
10from __future__ import annotations
12# <tenant-slug>/<REG>/photos/ — aircraft photos (AircraftPhoto rows).
13PHOTOS_DIRNAME = "photos"
14# <tenant-slug>/<REG>/gps_logs/ — original GPS log files (services.gps_archive).
15GPS_ARCHIVE_DIRNAME = "gps_logs"
16# _pilots/<user-id>/gps_logs/ — a pilot's own original GPS log files. Tenant
17# slugs are [a-z0-9-] only, so this top-level folder can never clash with a
18# tenant's folder (nor is it walked by the scanners, which only walk those).
19PILOT_ARCHIVE_ROOT = "_pilots"
21_APP_MANAGED_AIRCRAFT_DIRS = frozenset({PHOTOS_DIRNAME, GPS_ARCHIVE_DIRNAME})
24def is_app_managed(relpath: str) -> bool:
25 """True for a file (path relative to UPLOAD_FOLDER, "/"-separated) in
26 one of an aircraft's app-managed folders — never a document."""
27 parts = relpath.split("/")
28 return len(parts) >= 4 and parts[2] in _APP_MANAGED_AIRCRAFT_DIRS