fix: disable Analyse on active recordings; guard server-side too

Clicking Analyse on a file currently being recorded caused libsndfile to
fail with 'Internal psf_fseek() failed' because an in-progress FLAC file
has no seektable (written only on close()).

Client: Analyse button is disabled with a tooltip while isRec is true.
Server: _api_analyze checks status.json and returns 409 with a readable
message if the file is still being recorded, before attempting to open it.
This commit is contained in:
2026-04-26 14:44:37 +02:00
parent 9ac23e9f1d
commit d7524afeff
+15 -1
View File
@@ -272,6 +272,15 @@ class _Handler(BaseHTTPRequestHandler):
if path is None:
return
status_path = Path(self.recordings_dir) / 'status.json'
try:
with open(status_path) as fh:
if filename in set(json.load(fh).get('active', [])):
self._json_err(409, 'File is currently being recorded — analysis unavailable until recording stops')
return
except Exception:
pass
ext = path.suffix.lower()
if ext == '.wav':
result = analyze_wav(path, threshold=self.threshold)
@@ -691,7 +700,12 @@ async function load() {
const abtn = document.createElement('button');
abtn.textContent = 'Analyse';
abtn.setAttribute('aria-label', `Analyse loudness of ${f.name}`);
abtn.addEventListener('click', () => analyse(f.name, cell, abtn));
if (isRec) {
abtn.disabled = true;
abtn.title = 'Recording in progress — analyse after recording stops';
} else {
abtn.addEventListener('click', () => analyse(f.name, cell, abtn));
}
cell.appendChild(abtn);
}