From edb97c21d72ff41fa377cf2edd326626a08d39c6 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Fri, 1 Nov 2013 08:11:17 +0100 Subject: [PATCH] Handles a corner case when clearing hash when loading the content file. --- state.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/state.c b/state.c index a9007fe0..349e8efc 100644 --- a/state.c +++ b/state.c @@ -879,6 +879,11 @@ static void state_content_check(struct snapraid_state* state, const char* path) * Checks if a block position is used by at least one disk * and has a hash value. * Note that we include DELETED blocks, but only if they have a not NULL hash. + * + * This is needed to know if for such block we have to keep the "rehash" info + * or if we can drop it. + * Note that even if the block is not used by any file, the presence of a + * DELETE block with hash, will maintain the info. */ static int position_has_any_hash(struct snapraid_state* state, block_off_t pos) { @@ -2393,10 +2398,14 @@ static void state_read_binary(struct snapraid_state* state, const char* path, ST exit(EXIT_FAILURE); } } else { - if (info) { - decoding_error(path, f); - fprintf(stderr, "Internal inconsistency for unexpected info!\n"); - exit(EXIT_FAILURE); + /* if we are clearing hashes, it's possible that */ + /* we have info even if no hash is present */ + if (!state->clear_undeterminate_hash) { + if (info) { + decoding_error(path, f); + fprintf(stderr, "Internal inconsistency for unexpected info!\n"); + exit(EXIT_FAILURE); + } } }