Add broken symlink diagnostics

This commit is contained in:
Philip Guzman
2026-07-01 07:32:07 -07:00
parent c5449a278a
commit b8ea17450b
11 changed files with 145 additions and 9 deletions
+20 -2
View File
@@ -1,14 +1,23 @@
from pathlib import Path
from serato_doctor.models.filesystem import BrokenSymlink, FilesystemScan
from serato_doctor.models.track import DiskTrack
AUDIO_SUFFIXES = {".mp3", ".m4a", ".wav", ".aif", ".aiff", ".flac"}
def scan_audio(folder: Path) -> list[DiskTrack]:
def scan_filesystem(folder: Path) -> FilesystemScan:
tracks = []
broken_symlinks = []
for path in folder.rglob("*"):
if path.is_symlink() and not path.exists():
try:
target = path.readlink()
except OSError:
target = None
broken_symlinks.append(BrokenSymlink(path=path, target=target))
continue
if not path.is_file():
continue
if path.suffix.lower() not in AUDIO_SUFFIXES:
@@ -28,4 +37,13 @@ def scan_audio(folder: Path) -> list[DiskTrack]:
)
)
return tracks
return FilesystemScan(
tracks=tuple(tracks),
broken_symlinks=tuple(broken_symlinks),
)
def scan_audio(folder: Path) -> list[DiskTrack]:
"""Scan audio files while preserving the prototype API."""
return list(scan_filesystem(folder).tracks)