From 41a3692430b90a1f48ad4a9ae0db5f30b3134286 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Tue, 5 May 2015 22:09:46 +0200 Subject: [PATCH] Print more details in search/import if a file disappears --- cmdline/import.c | 7 ++++++- cmdline/search.c | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/cmdline/import.c b/cmdline/import.c index 566cba8f..3f435bd3 100644 --- a/cmdline/import.c +++ b/cmdline/import.c @@ -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 */ } diff --git a/cmdline/search.c b/cmdline/search.c index 210cfdd9..031c4f03 100644 --- a/cmdline/search.c +++ b/cmdline/search.c @@ -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 */ }