From 713462dfdf3c46a998b43525cbbf5ae0ec8ea84b Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Mon, 29 Dec 2025 00:31:20 +0100 Subject: avoid unnecessary cleanups of recovery files * After the last commit 0b593eb7d0e6907b19cdbb605caf1becae351004 we tried to clean up (unlink) recovery files for all dirty buffers. This resulted in superfluous file deletions before any recovery file was dumped; after disabling file recovery and even in batch mode. It's not tolerable that SciTECO scripts try to unlink files as a side effect e.g. of EW. Also, sometimes you may have to clean up recovery dumps even in batch mode, e.g. in Quit hooks. * Also, it was broken for dirty unnamed buffers, which would cause glib errors. * That's why we had to add another buffer state for dirty files with outdated recovery dumps (TECO_BUFFER_DIRTY_OUTDATED_DUMP). Once a dump was written, a buffer never directly transitions into the TECO_BUFFER_DIRTY_NO_DUMP state again. We can now reliably unlink() only where we'd expect a recovery file to exist in the first place. --- src/ring.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/ring.h') diff --git a/src/ring.h b/src/ring.h index 4624983..d81c3db 100644 --- a/src/ring.h +++ b/src/ring.h @@ -28,10 +28,12 @@ typedef enum { /** buffer is freshly opened or saved */ TECO_BUFFER_CLEAN = 0, - /** buffer modified - if a recovery file already exists, it is outdated */ - TECO_BUFFER_DIRTY, - /** buffer modified and recovery file already written */ - TECO_BUFFER_DIRTY_DUMPED + /** buffer modified, but a recovery file does not yet exist */ + TECO_BUFFER_DIRTY_NO_DUMP, + /** buffer modified, recovery file outdated */ + TECO_BUFFER_DIRTY_OUTDATED_DUMP, + /** buffer modified and recovery file is up to date */ + TECO_BUFFER_DIRTY_RECENT_DUMP } teco_buffer_state_t; typedef struct teco_buffer_t { -- cgit v1.2.3