mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-22 10:58:10 +01:00
restore: Make missing messages non-fatal (again)
Previously, restore would abort if a message ID in the dump was missing. Furthermore, it would only report this as a warning. This patch makes it distinguish abort-worthy lookup failures like out-of-memory from non-fatal failure to find a message ID. The former is reported as an error and causes restore to abort, while the latter is reported as a warning and does not cause an abort. This restores 0.14's non-fatal handling of missing message IDs in restore (though 0.14 also considered serious errors non-fatal; we retain the new and better handling of serious errors).
This commit is contained in:
parent
d705a6a45b
commit
baca1219af
1 changed files with 11 additions and 6 deletions
|
@ -26,7 +26,8 @@
|
||||||
static regex_t regex;
|
static regex_t regex;
|
||||||
|
|
||||||
/* Non-zero return indicates an error in retrieving the message,
|
/* Non-zero return indicates an error in retrieving the message,
|
||||||
* or in applying the tags.
|
* or in applying the tags. Missing messages are reported, but not
|
||||||
|
* considered errors.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
tag_message (unused (void *ctx),
|
tag_message (unused (void *ctx),
|
||||||
|
@ -40,13 +41,17 @@ tag_message (unused (void *ctx),
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
status = notmuch_database_find_message (notmuch, message_id, &message);
|
status = notmuch_database_find_message (notmuch, message_id, &message);
|
||||||
if (status || message == NULL) {
|
if (status) {
|
||||||
fprintf (stderr, "Warning: cannot apply tags to %smessage: %s\n",
|
fprintf (stderr, "Error applying tags to message %s: %s\n",
|
||||||
message ? "" : "missing ", message_id);
|
message_id, notmuch_status_to_string (status));
|
||||||
if (status)
|
|
||||||
fprintf (stderr, "%s\n", notmuch_status_to_string (status));
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
if (message == NULL) {
|
||||||
|
fprintf (stderr, "Warning: cannot apply tags to missing message: %s\n",
|
||||||
|
message_id);
|
||||||
|
/* We consider this a non-fatal error. */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* In order to detect missing messages, this check/optimization is
|
/* In order to detect missing messages, this check/optimization is
|
||||||
* intentionally done *after* first finding the message. */
|
* intentionally done *after* first finding the message. */
|
||||||
|
|
Loading…
Reference in a new issue