Adds a consistency check about missing previous hash.

This commit is contained in:
Andrea Mazzoleni 2013-08-01 19:36:12 +02:00
parent 0db2428132
commit 865fc0c1f4

View file

@ -1074,6 +1074,11 @@ void state_read(struct snapraid_state* state)
} else if (strcmp(buffer, "rehash") == 0) {
rehash = 1;
hash = oathash8(hash, 'y');
if (state->prevhash == HASH_UNDEFINED) {
fprintf(stderr, "Internal incosistency for missing previous checksum in '%s' at line %u\n", path, line);
exit(EXIT_FAILURE);
}
} else {
fprintf(stderr, "Invalid 'inf' specification '%s' in '%s' at line %u\n", buffer, path, line);
exit(EXIT_FAILURE);
@ -1701,7 +1706,7 @@ void state_read(struct snapraid_state* state)
if (state->hash == HASH_UNDEFINED) {
fprintf(stderr, "The checksum to use is not specified.\n");
fprintf(stderr, "This happens because you are likely upgrading from SnapRAID 1.0.\n");
fprintf(stderr, "To use the SnapRAID 2.x branch, you must restart from scratch,\n");
fprintf(stderr, "To use a new SnapRAID you must restart from scratch,\n");
fprintf(stderr, "deleting all the content and parity files.\n");
exit(EXIT_FAILURE);
}