This is a Docker volume issue, not a code bug. The backend container only sees paths explicitly mounted in docker-compose.yml. A new mount on the Linux host (e.g. NAS share, USB drive) is invisible to the container until added as a volume — restarting the container alone doesn't help, and restarting just the host doesn't either. Backend: New GET /api/filebrowser/diagnose endpoint reads /proc/self/mountinfo and returns the actual bind/nfs/cifs mounts the container sees, plus a check of common candidate roots (/audiofiles, /mnt, /media, /srv, /home, /app/data) showing whether they exist and have content. Frontend: Info icon in FileBrowser header toggles a diagnose panel showing mounts and root candidates. Quick-access buttons now built dynamically from candidate roots that actually exist. On 'path not found' error: helpful inline explanation including the exact .env variable and docker-compose command needed to add a new mount. docker-compose.yml: New EXTRA_AUDIO_PATH env variable. Mounts a second host path 1:1 (same path inside container, like AUDIOFILES_PATH does). Defaults to ./data → /extra_audio_unused when unset, which is a no-op. .env.example: Documents EXTRA_AUDIO_PATH usage with example. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
99 lines
3.5 KiB
Python
99 lines
3.5 KiB
Python
import os
|
|
from fastapi import APIRouter, Depends, HTTPException, Query
|
|
from ..dependencies import require_admin
|
|
from ..models.user import User
|
|
|
|
router = APIRouter(prefix="/api/filebrowser", tags=["filebrowser"])
|
|
|
|
|
|
@router.get("")
|
|
async def browse(
|
|
path: str = Query("/"),
|
|
_admin: User = Depends(require_admin),
|
|
):
|
|
path = os.path.normpath(path)
|
|
if not os.path.isdir(path):
|
|
raise HTTPException(status_code=404, detail="Pfad nicht gefunden")
|
|
|
|
try:
|
|
names = sorted(os.listdir(path), key=lambda n: n.lower())
|
|
except PermissionError:
|
|
raise HTTPException(status_code=403, detail="Zugriff verweigert")
|
|
|
|
entries = []
|
|
for name in names:
|
|
if name.startswith("."):
|
|
continue
|
|
full = os.path.join(path, name)
|
|
try:
|
|
is_dir = os.path.isdir(full)
|
|
except OSError:
|
|
continue
|
|
entries.append({"name": name, "path": full, "isDir": is_dir})
|
|
|
|
parent_path = os.path.dirname(path)
|
|
parent = parent_path if parent_path != path else None
|
|
|
|
return {"path": path, "parent": parent, "entries": entries}
|
|
|
|
|
|
@router.get("/diagnose")
|
|
async def diagnose(_admin: User = Depends(require_admin)):
|
|
"""Zeigt was der Backend-Container sieht: Bind-Mounts und Top-Level-Verzeichnisse."""
|
|
# Aktive Mounts aus /proc/self/mountinfo
|
|
mounts = []
|
|
try:
|
|
with open("/proc/self/mountinfo", "r") as f:
|
|
for line in f:
|
|
parts = line.split()
|
|
# Format: id parent major:minor root mount_point options - fstype source super_options
|
|
if len(parts) < 10 or "-" not in parts:
|
|
continue
|
|
sep = parts.index("-")
|
|
mount_point = parts[4]
|
|
fstype = parts[sep + 1] if sep + 1 < len(parts) else "?"
|
|
source = parts[sep + 2] if sep + 2 < len(parts) else "?"
|
|
# Interne Kernel-Mounts überspringen
|
|
if any(mount_point.startswith(p) for p in ("/proc", "/sys", "/dev", "/etc/", "/run", "/tmp")):
|
|
continue
|
|
if mount_point in ("/", "/etc/resolv.conf", "/etc/hostname", "/etc/hosts"):
|
|
continue
|
|
mounts.append({
|
|
"mountPoint": mount_point,
|
|
"fsType": fstype,
|
|
"source": source,
|
|
})
|
|
except Exception as e:
|
|
mounts_error = str(e)
|
|
else:
|
|
mounts_error = None
|
|
|
|
# Top-Level-Verzeichnisse die im Container existieren und für Hörbücher in Frage kommen
|
|
candidates = ["/audiofiles", "/mnt", "/media", "/srv", "/home", "/app/data"]
|
|
roots = []
|
|
for p in candidates:
|
|
if os.path.isdir(p):
|
|
try:
|
|
entries = os.listdir(p)
|
|
roots.append({
|
|
"path": p,
|
|
"exists": True,
|
|
"entryCount": len([e for e in entries if not e.startswith(".")]),
|
|
})
|
|
except PermissionError:
|
|
roots.append({"path": p, "exists": True, "entryCount": None, "permError": True})
|
|
else:
|
|
roots.append({"path": p, "exists": False})
|
|
|
|
return {
|
|
"mounts": mounts,
|
|
"mountsError": mounts_error,
|
|
"candidateRoots": roots,
|
|
"hint": (
|
|
"Pfade die hier NICHT in 'mounts' auftauchen, sind im Container nicht sichtbar. "
|
|
"Sie müssen in docker-compose.yml als Volume gemountet werden — "
|
|
"z.B. via EXTRA_AUDIO_PATH=/dein/host/pfad in der .env und dann "
|
|
"'docker-compose down && docker-compose up -d'."
|
|
),
|
|
}
|