Previously we just crashed with an internal error. With this change,
the caller can handle it better, although the error code could be
further improved.
---
lib/message.cc | 15 +++++++++++----
test/T050-new.sh | 1 -
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/lib/message.cc b/lib/message.cc
index 1c87f8c0..0e6ea809 100644
--- a/lib/message.cc
+++ b/lib/message.cc
@@ -941,6 +941,7 @@ _notmuch_message_add_filename (notmuch_message_t *message,
{
const char *relative, *directory;
notmuch_status_t status;
+ notmuch_private_status_t private_status;
void *local = talloc_new (message);
char *direntry;
@@ -964,10 +965,16 @@ _notmuch_message_add_filename (notmuch_message_t *message,
/* New file-direntry allows navigating to this message with
* notmuch_directory_get_child_files() . */
- status = COERCE_STATUS (_notmuch_message_add_term (message, "file-direntry", direntry),
- "adding file-direntry term");
- if (status)
- return status;
+ private_status =_notmuch_message_add_term (message, "file-direntry", direntry);
+ switch (private_status) {
+ case NOTMUCH_PRIVATE_STATUS_SUCCESS:
+ break;
+ case NOTMUCH_PRIVATE_STATUS_TERM_TOO_LONG:
+ _notmuch_database_log(message->notmuch, "filename too long for file-direntry term: %s\n", filename);
+ return NOTMUCH_STATUS_FILE_ERROR;
+ default:
+ return COERCE_STATUS (private_status, "adding file-direntry term");
+ }
status = _notmuch_message_add_folder_terms (message, directory);
if (status)
diff --git a/test/T050-new.sh b/test/T050-new.sh
index 74890928..bf086609 100755
--- a/test/T050-new.sh
+++ b/test/T050-new.sh
@@ -384,7 +384,6 @@ EOF
test_expect_equal_file EXPECTED OUTPUT
test_begin_subtest "Long file names have reasonable diagnostics"
-test_subtest_known_broken
printf -v name 'f%.0s' {1..234}
generate_message "[filename]=$name"
notmuch new 2>&1 | notmuch_dir_sanitize >OUTPUT
--
2.35.2
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org