Print more details in search/import if a file disappears

This commit is contained in:
Andrea Mazzoleni 2015-05-05 22:09:46 +02:00
parent a31624f95a
commit 41a3692430
2 changed files with 12 additions and 2 deletions

View file

@ -174,7 +174,12 @@ int state_import_fetch(struct snapraid_state* state, int rehash, struct snapraid
f = open(path, O_RDONLY | O_BINARY);
if (f == -1) {
/* LCOV_EXCL_START */
log_fatal("Error opening file '%s'. %s.\n", path, strerror(errno));
if (errno == ENOENT) {
log_fatal("DANGER! file '%s' disappeared.\n", path);
log_fatal("If you moved it, please rerun the same command.\n");
} else {
log_fatal("Error opening file '%s'. %s.\n", path, strerror(errno));
}
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}

View file

@ -79,7 +79,12 @@ int search_file_compare(const void* void_arg, const void* void_data)
f = open(path, O_RDONLY | O_BINARY);
if (f == -1) {
/* LCOV_EXCL_START */
log_fatal("Error opening file '%s'. %s.\n", path, strerror(errno));
if (errno == ENOENT) {
log_fatal("DANGER! file '%s' disappeared.\n", path);
log_fatal("If you moved it, please rerun the same command.\n");
} else {
log_fatal("Error opening file '%s'. %s.\n", path, strerror(errno));
}
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}