Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 0BD38431FC4 for ; Sun, 30 Mar 2014 14:22:07 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id UhbJFXkxd60N for ; Sun, 30 Mar 2014 14:22:00 -0700 (PDT) Received: from mail-wg0-f44.google.com (mail-wg0-f44.google.com [74.125.82.44]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id C97CC431FBC for ; Sun, 30 Mar 2014 14:21:59 -0700 (PDT) Received: by mail-wg0-f44.google.com with SMTP id m15so5039419wgh.15 for ; Sun, 30 Mar 2014 14:21:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=OuCS9eRmeybqdM6ZNHJ2bkHInjTutM6x/HnMoPs7OlQ=; b=TrCc63oPUiTcT0ub4g/L0AuoVAKWQFkckpsl+kr03CJJKyK3Fts7L2nh3kqofJArJV NRgwb9j84Cshe1LyfQKyvo6zHGICPkNy4qt/Xw/QEBpYn2fmjlgjRti3m/WOShMAXSc1 imI9fTP2gpaS29wVZzhsUmf/iNyQ716Jwj7Ar4Va6/OoVaCojxZ2XZZ3Uul4OJ9pWRdQ dt3SgVFph3NlI0biQhXftckaNGGsn9j7U/vbP0FhlneaHtQJCjrrHv/nqfdEmzL+YgLV c5ePyz+r3UfmOCD/zvuBIHPcOcenA31L+5wB/RBUeSl50g6fiJRqtdUGlybgRAURnaAX HhmQ== X-Gm-Message-State: ALoCoQmCQwvKAF7HwzgdvLiB4dDG8fhKAX9j7/Edj+SsNcwE9muMOpvV6yKZchYPAVJJjaN8A7gC X-Received: by 10.194.48.100 with SMTP id k4mr728248wjn.49.1396214515840; Sun, 30 Mar 2014 14:21:55 -0700 (PDT) Received: from localhost (dsl-hkibrasgw2-58c36f-91.dhcp.inet.fi. [88.195.111.91]) by mx.google.com with ESMTPSA id p8sm28327681eef.26.2014.03.30.14.21.54 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sun, 30 Mar 2014 14:21:55 -0700 (PDT) From: Jani Nikula To: notmuch@notmuchmail.org Subject: [PATCH v5 1/2] lib: drop support for single-message mbox files Date: Mon, 31 Mar 2014 00:21:48 +0300 Message-Id: <657fe62a36d8f6a0b8464f191c2adc95d00de183.1396214154.git.jani@nikula.org> X-Mailer: git-send-email 1.9.0 In-Reply-To: References: In-Reply-To: References: X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Mar 2014 21:22:07 -0000 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. --- lib/index.cc | 28 +++++----------------------- test/T050-new.sh | 26 ++++++++++---------------- 2 files changed, 15 insertions(+), 39 deletions(-) diff --git a/lib/index.cc b/lib/index.cc index 78c18cf36d10..2100cce04780 100644 --- a/lib/index.cc +++ b/lib/index.cc @@ -436,8 +436,6 @@ _notmuch_message_index_file (notmuch_message_t *message, notmuch_status_t ret = NOTMUCH_STATUS_SUCCESS; static int initialized = 0; char from_buf[5]; - bool is_mbox = false; - static bool mbox_warning = false; if (! initialized) { g_mime_init (GMIME_ENABLE_RFC2047_WORKAROUNDS); @@ -453,36 +451,20 @@ _notmuch_message_index_file (notmuch_message_t *message, /* Is this mbox? */ if (fread (from_buf, sizeof (from_buf), 1, file) == 1 && - strncmp (from_buf, "From ", 5) == 0) - is_mbox = true; + strncmp (from_buf, "From ", 5) == 0) { + ret = NOTMUCH_STATUS_FILE_NOT_EMAIL; + goto DONE; + } rewind (file); /* Evil GMime steals my FILE* here so I won't fclose it. */ stream = g_mime_stream_file_new (file); 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); - 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); addresses = internet_address_list_parse_string (from); diff --git a/test/T050-new.sh b/test/T050-new.sh index ad46ee6d51b6..3c3195428223 100755 --- a/test/T050-new.sh +++ b/test/T050-new.sh @@ -163,22 +163,6 @@ rm -rf "${MAIL_DIR}"/two output=$(NOTMUCH_NEW) test_expect_equal "$output" "No new mail. Removed 3 messages." -test_begin_subtest "Support single-message mbox (deprecated)" -cat > "${MAIL_DIR}"/mbox_file1 < -To: Notmuch Test Suite -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. test_begin_subtest "Skip and report non-mail files" generate_message @@ -200,14 +184,24 @@ Subject: Test mbox message 2 Body 2. EOF +cat > "${MAIL_DIR}"/mbox_file1 < +To: Notmuch Test Suite +Subject: Test mbox message 1 + +Body. +EOF output=$(NOTMUCH_NEW 2>&1) test_expect_equal "$output" \ "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_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." rm "${MAIL_DIR}"/mbox_file +rm "${MAIL_DIR}"/mbox_file1 test_begin_subtest "Ignore files and directories specified in new.ignore" generate_message -- 1.9.0