diff --git a/web.py b/web.py index 91357ad..4a3e879 100644 --- a/web.py +++ b/web.py @@ -222,10 +222,14 @@ def list_files(recordings_dir: str): for path in base.rglob('*'): if path.suffix.lower() not in AUDIO_EXTENSIONS: continue - stat = path.stat() - rel = str(path.relative_to(base)).replace('\\', '/') + stat = path.stat() + rel = str(path.relative_to(base)).replace('\\', '/') + is_active = rel in active_files - duration = _get_audio_duration(path) + # Skip reading partial headers for in-progress files — the WAV nframes + # field and FLAC total_samples are both unfinalized while recording, + # producing wildly incorrect values (e.g. 53375995583:39:01). + duration = None if is_active else _get_audio_duration(path) files.append({ 'name': rel, @@ -234,7 +238,7 @@ def list_files(recordings_dir: str): 'date': datetime.fromtimestamp(stat.st_mtime).strftime('%Y-%m-%d %H:%M:%S'), 'duration': duration, 'ext': path.suffix.lower().lstrip('.'), - 'recording': rel in active_files, + 'recording': is_active, }) files.sort(key=lambda f: f['mtime'], reverse=True)