From 53c05d93e2414f9dcbf7dc3760fa4ee953a5b1ef Mon Sep 17 00:00:00 2001 From: serversdown Date: Thu, 28 May 2026 05:31:08 +0000 Subject: [PATCH] delete: also clean up preserved _ASCII.TXT file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit _cleanup_event_files() removes the on-disk artifacts when an event is hard-deleted (binary, a5_pickle, sidecar, h5). Today's .TXT preservation feature added a new on-disk file (_ASCII.TXT next to the binary) but the cleanup didn't know about it — so any event deleted via /db/events/{id} (single) or /db/events/delete_bulk (or the Terra-View "SFM Event DB Manager" UI which proxies through to those endpoints) was leaving orphan .TXT files in the store. Added "txt" to the cleanup list using the new WaveformStore.txt_path_for(). Safe for old events without a .TXT — the exists() check skips the unlink. Co-Authored-By: Claude Opus 4.7 (1M context) --- sfm/server.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/sfm/server.py b/sfm/server.py index 93ee110..ed42775 100644 --- a/sfm/server.py +++ b/sfm/server.py @@ -1987,10 +1987,15 @@ def _cleanup_event_files(row: dict) -> dict: base_name = bw_name or a5_name or sc_name if base_name: bw_path, a5_path = store.paths_for(serial, base_name) - sc_path = store.sidecar_path_for(serial, base_name) - h5_path = store.hdf5_path_for(serial, base_name) + sc_path = store.sidecar_path_for(serial, base_name) + h5_path = store.hdf5_path_for(serial, base_name) + # Preserved BW ASCII report (added 2026-05-27 with the .TXT + # preservation feature) — needs to be cleaned up too, otherwise + # deletes leave orphan _ASCII.TXT files behind. + txt_path = store.txt_path_for(serial, base_name) for kind, p in [("blastware", bw_path), ("a5_pickle", a5_path), - ("sidecar", sc_path), ("hdf5", h5_path)]: + ("sidecar", sc_path), ("hdf5", h5_path), + ("txt", txt_path)]: try: if p.exists(): p.unlink()