FileBrowser: diagnose container mounts + support extra audio path
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>
This commit is contained in:
@@ -35,3 +35,64 @@ async def browse(
|
||||
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'."
|
||||
),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user