From e76441e789be997d319758645a5d844a1b940886 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Thu, 5 Jun 2014 23:06:13 +0200 Subject: [PATCH] With the nocopy option also remove hash info from previous sync. If we want to disable the automatic hashing assumption of copy, we need also to remove any previous hash info already stored in the content file by previous sync commands run without the nocopy option. --- cmdline/scan.c | 2 +- cmdline/state.c | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/cmdline/scan.c b/cmdline/scan.c index 1b71a32f..b0c7014d 100644 --- a/cmdline/scan.c +++ b/cmdline/scan.c @@ -602,7 +602,7 @@ static void scan_file(struct snapraid_scan* scan, int output, const char* sub, c add_insert = 0; add_change = 0; - /* then try findind it by name */ + /* then try finding it by name */ file = tommy_hashdyn_search(&disk->pathset, file_path_compare_to_arg, sub, file_path_hash(sub)); if (file) { /* if the file is without an inode */ diff --git a/cmdline/state.c b/cmdline/state.c index b7dc2997..9a3f15f4 100644 --- a/cmdline/state.c +++ b/cmdline/state.c @@ -1340,6 +1340,18 @@ static void state_read_text(struct snapraid_state* state, const char* path, STRE hash_invalid_set(block->hash); } + /* if we are disabling the copy optimization */ + /* we want also to clear any already previously stored information */ + /* in other sync commands */ + if (state->opt.force_nocopy + && block_state_get(block) == BLOCK_STATE_REP + ) { + /* set the hash value to INVALID */ + hash_invalid_set(block->hash); + /* convert from REP to CHG block */ + block_state_set(block, BLOCK_STATE_CHG); + } + /* we must not overwrite existing blocks */ if (disk_block_get(disk, v_pos) != BLOCK_EMPTY) { /* LCOV_EXCL_START */ @@ -2827,6 +2839,18 @@ static void state_read_binary(struct snapraid_state* state, const char* path, ST hash_invalid_set(block->hash); } + /* if we are disabling the copy optimization */ + /* we want also to clear any already previously stored information */ + /* in other sync commands */ + if (state->opt.force_nocopy + && block_state_get(block) == BLOCK_STATE_REP + ) { + /* set the hash value to INVALID */ + hash_invalid_set(block->hash); + /* convert from REP to CHG block */ + block_state_set(block, BLOCK_STATE_CHG); + } + /* we must not overwrite existing blocks */ if (disk_block_get(disk, v_pos) != BLOCK_EMPTY) { /* LCOV_EXCL_START */