Sets NEW hash to 0 when converting them to DELETED blocks.

This avoids to use not initialized hash for deleted blocks,
when deleting files after an aborted sync.
This commit is contained in:
Andrea Mazzoleni 2013-10-27 20:59:37 +01:00
parent 7414f8daec
commit 18deae30a4

5
scan.c
View file

@ -170,8 +170,11 @@ static void scan_file_remove(struct snapraid_state* state, struct snapraid_disk*
case BLOCK_STATE_BLK :
/* we keep the hash making it an "old" hash, because the parity is still containing data for it */
break;
case BLOCK_STATE_CHG :
case BLOCK_STATE_NEW :
/* NEW blocks don't have a hash, then we set it to the 'unspecified' 0 value */
memset(block->hash, 0, HASH_SIZE);
break;
case BLOCK_STATE_CHG :
/* if we have not already cleared the undeterminated hash */
if (!state->clear_undeterminate_hash) {
/* in these cases we don't know if the old state is still the one */