mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 02:49:02 -04:00
Restore file mtime after synced-only recovery writes
This commit is contained in:
parent
46dbfa9b08
commit
5b0a8e0c8e
2 changed files with 34 additions and 0 deletions
|
|
@ -1822,6 +1822,26 @@ static int file_recover(struct snapraid_state* state, int fix, int partial, bloc
|
||||||
/* LCOV_EXCL_STOP */
|
/* LCOV_EXCL_STOP */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* A recovery write changes the file modification time. With syncedonly,
|
||||||
|
* later recovery writes are allowed only while the file still matches
|
||||||
|
* the metadata stored in the content file. Restore the original mtime
|
||||||
|
* after every successful write so an interruption between blocks does
|
||||||
|
* not make a partially recovered file appear unsynced on the next run.
|
||||||
|
*/
|
||||||
|
if (state->opt.syncedonly) {
|
||||||
|
ret = handle_utime(failed[j].handle);
|
||||||
|
if (ret == -1) {
|
||||||
|
/* LCOV_EXCL_START */
|
||||||
|
file_flag_set(failed[j].file, FILE_IS_DAMAGED);
|
||||||
|
log_tag("%s:%" PRIu64 ":%s:%s: Time error. %s.\n", es(errno), block_pos, failed[j].disk->name, esc_tag(failed[j].file->sub), strerror(errno));
|
||||||
|
log_fatal_errno(errno, failed[j].disk->name);
|
||||||
|
log_fatal(errno, "Stopping at block %" PRIu64 "\n", block_pos);
|
||||||
|
return -1;
|
||||||
|
/* LCOV_EXCL_STOP */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* if we are not sure that the recovered content is uptodate */
|
/* if we are not sure that the recovered content is uptodate */
|
||||||
if (failed[j].recovery == RECOVERY_OUTOFDATE)
|
if (failed[j].recovery == RECOVERY_OUTOFDATE)
|
||||||
continue;
|
continue;
|
||||||
|
|
|
||||||
|
|
@ -1280,6 +1280,20 @@ int snapraid_main(int argc, char* argv[])
|
||||||
/* LCOV_EXCL_STOP */
|
/* LCOV_EXCL_STOP */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (opt.syncedonly && blockstart_set) {
|
||||||
|
/* LCOV_EXCL_START */
|
||||||
|
log_fatal(EUSER, "You cannot use -S, --start with -e, --filter-error or -b, --filter-block-error\n");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
/* LCOV_EXCL_STOP */
|
||||||
|
}
|
||||||
|
|
||||||
|
if (opt.syncedonly && blockcount_set) {
|
||||||
|
/* LCOV_EXCL_START */
|
||||||
|
log_fatal(EUSER, "You cannot use -B, --count with -e, --filter-error or -b, --filter-block-error\n");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
/* LCOV_EXCL_STOP */
|
||||||
|
}
|
||||||
|
|
||||||
if (opt.prehash && opt.force_nocopy) {
|
if (opt.prehash && opt.force_nocopy) {
|
||||||
/* LCOV_EXCL_START */
|
/* LCOV_EXCL_START */
|
||||||
log_fatal(EUSER, "You cannot use the -h, --pre-hash and -N, --force-nocopy options simultaneously\n");
|
log_fatal(EUSER, "You cannot use the -h, --pre-hash and -N, --force-nocopy options simultaneously\n");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue