Avoid the duplicated 'Missing file' message

When fixing with filters, the filtered out files
were reported multiple times as missing.
We now mark if a file is missing, and we avoid
to try to open it multiple times.
This commit is contained in:
Andrea Mazzoleni 2015-10-15 19:34:58 +02:00
parent c6526a1a97
commit 841e6306e3
2 changed files with 18 additions and 3 deletions

View file

@ -1033,9 +1033,12 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
file_flag_set(file, FILE_IS_CREATED);
}
} else {
/* otherwise, open the file only for reading */
ret = handle_open(&handle[j], file, state->file_mode,
log_error, state->opt.expected_missing ? log_expected : 0);
/* open the file only for reading */
if (!file_flag_has(file, FILE_IS_MISSING))
ret = handle_open(&handle[j], file, state->file_mode,
log_error, state->opt.expected_missing ? log_expected : 0);
else
ret = -1; /* if the file is missing, we cannot open it */
if (ret == -1) {
/* save the failed block for the check/fix */
failed[failed_count].is_bad = 1;
@ -1050,6 +1053,11 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
log_tag("error:%u:%s:%s: Open error at position %u\n", i, disk->name, esc(file->sub), file_pos);
++error;
/* mark the file as missing, to avoid to retry to open it again */
/* note that this can be done only if we are not fixing it */
/* otherwise, it could be recreated */
file_flag_set(file, FILE_IS_MISSING);
continue;
}
}

View file

@ -239,6 +239,13 @@ struct snapraid_block {
*/
#define FILE_IS_DELETED 0x400
/**
* The file is missing.
* This happens in fix/check when a file is cannot be opened,
* and marking it as such prevents to retry to open it again.
*/
#define FILE_IS_MISSING 0x800
#define FILE_IS_HARDLINK 0x1000 /**< If it's an hardlink. */
#define FILE_IS_SYMLINK 0x2000 /**< If it's a file symlink. */
#define FILE_IS_SYMDIR 0x4000 /**< If it's a dir symlink for Windows. Not yet supported. */