From e5d5c512b8139dd46a781f71cc8cb32ff9139cb7 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Sun, 30 Aug 2026 21:53:51 +0200 Subject: [PATCH] Reject rehash while an incomplete sync is pending --- cmdline/rehash.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cmdline/rehash.c b/cmdline/rehash.c index 24eb4687..57ae1061 100644 --- a/cmdline/rehash.c +++ b/cmdline/rehash.c @@ -38,6 +38,16 @@ void state_rehash(struct snapraid_state* state) /* LCOV_EXCL_STOP */ } + /* a rehash can start only from a fully synchronized state */ + if (state->unsynced_blocks != 0) { + /* LCOV_EXCL_START */ + log_tag("summary:exit:sync_required\n"); + log_fatal(EUSER, "You cannot start a rehash with an incomplete sync.\n"); + log_fatal(EUSER, "Run 'snapraid sync' first.\n"); + exit(EXIT_FAILURE); + /* LCOV_EXCL_STOP */ + } + /* copy the present hash as previous one */ state->prevhash = state->hash; memcpy(state->prevhashseed, state->hashseed, HASH_MAX);