mirror of
https://git.notmuchmail.org/git/notmuch
synced 2025-01-03 07:11:41 +01:00
lib: drop support for single-message mbox files
We've supported mbox files containing a single message for historical reasons, but the support has been deprecated, with a warning message while indexing, since Notmuch 0.15. Finally drop the support, and consider all mbox files non-email.
This commit is contained in:
parent
3863755f6d
commit
6812136bf5
2 changed files with 15 additions and 39 deletions
28
lib/index.cc
28
lib/index.cc
|
@ -436,8 +436,6 @@ _notmuch_message_index_file (notmuch_message_t *message,
|
||||||
notmuch_status_t ret = NOTMUCH_STATUS_SUCCESS;
|
notmuch_status_t ret = NOTMUCH_STATUS_SUCCESS;
|
||||||
static int initialized = 0;
|
static int initialized = 0;
|
||||||
char from_buf[5];
|
char from_buf[5];
|
||||||
bool is_mbox = false;
|
|
||||||
static bool mbox_warning = false;
|
|
||||||
|
|
||||||
if (! initialized) {
|
if (! initialized) {
|
||||||
g_mime_init (GMIME_ENABLE_RFC2047_WORKAROUNDS);
|
g_mime_init (GMIME_ENABLE_RFC2047_WORKAROUNDS);
|
||||||
|
@ -453,36 +451,20 @@ _notmuch_message_index_file (notmuch_message_t *message,
|
||||||
|
|
||||||
/* Is this mbox? */
|
/* Is this mbox? */
|
||||||
if (fread (from_buf, sizeof (from_buf), 1, file) == 1 &&
|
if (fread (from_buf, sizeof (from_buf), 1, file) == 1 &&
|
||||||
strncmp (from_buf, "From ", 5) == 0)
|
strncmp (from_buf, "From ", 5) == 0) {
|
||||||
is_mbox = true;
|
ret = NOTMUCH_STATUS_FILE_NOT_EMAIL;
|
||||||
|
goto DONE;
|
||||||
|
}
|
||||||
rewind (file);
|
rewind (file);
|
||||||
|
|
||||||
/* Evil GMime steals my FILE* here so I won't fclose it. */
|
/* Evil GMime steals my FILE* here so I won't fclose it. */
|
||||||
stream = g_mime_stream_file_new (file);
|
stream = g_mime_stream_file_new (file);
|
||||||
|
|
||||||
parser = g_mime_parser_new_with_stream (stream);
|
parser = g_mime_parser_new_with_stream (stream);
|
||||||
g_mime_parser_set_scan_from (parser, is_mbox);
|
g_mime_parser_set_scan_from (parser, FALSE);
|
||||||
|
|
||||||
mime_message = g_mime_parser_construct_message (parser);
|
mime_message = g_mime_parser_construct_message (parser);
|
||||||
|
|
||||||
if (is_mbox) {
|
|
||||||
if (!g_mime_parser_eos (parser)) {
|
|
||||||
/* This is a multi-message mbox. */
|
|
||||||
ret = NOTMUCH_STATUS_FILE_NOT_EMAIL;
|
|
||||||
goto DONE;
|
|
||||||
}
|
|
||||||
/* For historical reasons, we support single-message mboxes,
|
|
||||||
* but this behavior is likely to change in the future, so
|
|
||||||
* warn. */
|
|
||||||
if (!mbox_warning) {
|
|
||||||
mbox_warning = true;
|
|
||||||
fprintf (stderr, "\
|
|
||||||
Warning: %s is an mbox containing a single message,\n\
|
|
||||||
likely caused by misconfigured mail delivery. Support for single-message\n\
|
|
||||||
mboxes is deprecated and may be removed in the future.\n", filename);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
from = g_mime_message_get_sender (mime_message);
|
from = g_mime_message_get_sender (mime_message);
|
||||||
|
|
||||||
addresses = internet_address_list_parse_string (from);
|
addresses = internet_address_list_parse_string (from);
|
||||||
|
|
|
@ -163,22 +163,6 @@ rm -rf "${MAIL_DIR}"/two
|
||||||
output=$(NOTMUCH_NEW)
|
output=$(NOTMUCH_NEW)
|
||||||
test_expect_equal "$output" "No new mail. Removed 3 messages."
|
test_expect_equal "$output" "No new mail. Removed 3 messages."
|
||||||
|
|
||||||
test_begin_subtest "Support single-message mbox (deprecated)"
|
|
||||||
cat > "${MAIL_DIR}"/mbox_file1 <<EOF
|
|
||||||
From test_suite@notmuchmail.org Fri Jan 5 15:43:57 2001
|
|
||||||
From: Notmuch Test Suite <test_suite@notmuchmail.org>
|
|
||||||
To: Notmuch Test Suite <test_suite@notmuchmail.org>
|
|
||||||
Subject: Test mbox message 1
|
|
||||||
|
|
||||||
Body.
|
|
||||||
EOF
|
|
||||||
output=$(NOTMUCH_NEW 2>&1)
|
|
||||||
test_expect_equal "$output" \
|
|
||||||
"Warning: ${MAIL_DIR}/mbox_file1 is an mbox containing a single message,
|
|
||||||
likely caused by misconfigured mail delivery. Support for single-message
|
|
||||||
mboxes is deprecated and may be removed in the future.
|
|
||||||
Added 1 new message to the database."
|
|
||||||
|
|
||||||
# This test requires that notmuch new has been run at least once.
|
# This test requires that notmuch new has been run at least once.
|
||||||
test_begin_subtest "Skip and report non-mail files"
|
test_begin_subtest "Skip and report non-mail files"
|
||||||
generate_message
|
generate_message
|
||||||
|
@ -200,14 +184,24 @@ Subject: Test mbox message 2
|
||||||
|
|
||||||
Body 2.
|
Body 2.
|
||||||
EOF
|
EOF
|
||||||
|
cat > "${MAIL_DIR}"/mbox_file1 <<EOF
|
||||||
|
From test_suite@notmuchmail.org Fri Jan 5 15:43:57 2001
|
||||||
|
From: Notmuch Test Suite <test_suite@notmuchmail.org>
|
||||||
|
To: Notmuch Test Suite <test_suite@notmuchmail.org>
|
||||||
|
Subject: Test mbox message 1
|
||||||
|
|
||||||
|
Body.
|
||||||
|
EOF
|
||||||
output=$(NOTMUCH_NEW 2>&1)
|
output=$(NOTMUCH_NEW 2>&1)
|
||||||
test_expect_equal "$output" \
|
test_expect_equal "$output" \
|
||||||
"Note: Ignoring non-mail file: ${MAIL_DIR}/.git/config
|
"Note: Ignoring non-mail file: ${MAIL_DIR}/.git/config
|
||||||
Note: Ignoring non-mail file: ${MAIL_DIR}/.ignored_hidden_file
|
Note: Ignoring non-mail file: ${MAIL_DIR}/.ignored_hidden_file
|
||||||
Note: Ignoring non-mail file: ${MAIL_DIR}/ignored_file
|
Note: Ignoring non-mail file: ${MAIL_DIR}/ignored_file
|
||||||
Note: Ignoring non-mail file: ${MAIL_DIR}/mbox_file
|
Note: Ignoring non-mail file: ${MAIL_DIR}/mbox_file
|
||||||
|
Note: Ignoring non-mail file: ${MAIL_DIR}/mbox_file1
|
||||||
Added 1 new message to the database."
|
Added 1 new message to the database."
|
||||||
rm "${MAIL_DIR}"/mbox_file
|
rm "${MAIL_DIR}"/mbox_file
|
||||||
|
rm "${MAIL_DIR}"/mbox_file1
|
||||||
|
|
||||||
test_begin_subtest "Ignore files and directories specified in new.ignore"
|
test_begin_subtest "Ignore files and directories specified in new.ignore"
|
||||||
generate_message
|
generate_message
|
||||||
|
|
Loading…
Reference in a new issue