From d210e95997d9a7e39ea0dda82e2f82d27d22b972 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Mon, 28 Sep 2026 14:09:26 +0200 Subject: [PATCH] Avoid touch hiding files modified since the last sync --- cmdline/touch.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/cmdline/touch.c b/cmdline/touch.c index 2b966e34..192dcdd4 100644 --- a/cmdline/touch.c +++ b/cmdline/touch.c @@ -111,6 +111,19 @@ int state_touch(struct snapraid_state* state) /* LCOV_EXCL_STOP */ } + /* + * Touch only files that are still unchanged compared to + * the content file. Otherwise changing the timestamp here + * could hide a modification from the following scan. + */ + if (st.st_size != file->size + || st.st_mtime != file->mtime_sec + || STAT_NSEC(&st) != file->mtime_nsec + ) { + close(f); + continue; + } + /* set the tweaked modification time, with new nano seconds */ ret = fmtime(f, st.st_mtime, nsec); if (ret != 0) {