From 7db0e0870f641bca29e827d80808ddee3027b289 Mon Sep 17 00:00:00 2001 From: Jonathan Schuster Date: Wed, 29 Apr 2026 19:54:38 +0200 Subject: [PATCH] fix: skip duration read for active recordings to prevent garbage values MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit WAV nframes and FLAC total_samples are both unfinalized while the recorder has the file open, producing wildly wrong durations (e.g. 53375995583:39:01). Return None (shown as —) instead. --- web.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) 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)