From bff4bb237b74fdf3c8637e134ae93824eb40a464 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Mon, 28 Sep 2026 11:37:58 +0200 Subject: [PATCH] Avoid truncating untracked file tails during partial fix --- cmdline/check.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cmdline/check.c b/cmdline/check.c index b688c287..1a074244 100644 --- a/cmdline/check.c +++ b/cmdline/check.c @@ -2175,12 +2175,15 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna * Missing data inside a short file is handled block by block by normal * recovery writes, which extend the file as needed. * - * Extra data past the expected end is different: it has no content block and - * therefore no later block recovery can remove it. Fix must truncate that - * untracked tail explicitly. + * Extra data past the expected end has no content block and therefore requires + * a file-level truncate during a full fix. + * + * A partial -S/-B fix operates only at block level, so it must leave any + * untracked tail untouched, even if the file is larger than expected. */ if (!file_flag_has(file, FILE_IS_OPENED) && !file_flag_has(file, FILE_IS_EXCLUDED) + && !partial && !(state->opt.syncedonly && file_flag_has(file, FILE_IS_UNSYNCED)) && handle[j].st.st_size > file->size ) {