From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 7EB17431FBF for ; Sun, 22 Apr 2012 08:50:59 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org 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 CcgLaaed1bKJ for ; Sun, 22 Apr 2012 08:50:58 -0700 (PDT) Received: from dmz-mailsec-scanner-2.mit.edu (DMZ-MAILSEC-SCANNER-2.MIT.EDU [18.9.25.13]) by olra.theworths.org (Postfix) with ESMTP id 47842431FB6 for ; Sun, 22 Apr 2012 08:50:58 -0700 (PDT) X-AuditID: 1209190d-b7fbf6d0000008ba-9c-4f9428e18a83 Received: from mailhub-auth-2.mit.edu ( [18.7.62.36]) by dmz-mailsec-scanner-2.mit.edu (Symantec Messaging Gateway) with SMTP id CE.83.02234.1E8249F4; Sun, 22 Apr 2012 11:50:57 -0400 (EDT) Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id q3MFov2T024461; Sun, 22 Apr 2012 11:50:57 -0400 Received: from drake.mit.edu (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com [209.6.116.242]) (authenticated bits=0) (User authenticated as amdragon@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q3MFou7c003692 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Sun, 22 Apr 2012 11:50:57 -0400 (EDT) Received: from amthrax by drake.mit.edu with local (Exim 4.77) (envelope-from ) id 1SLz3w-0002fB-B0; Sun, 22 Apr 2012 11:50:56 -0400 From: Austin Clements To: notmuch@notmuchmail.org Subject: [PATCH v3 1/4] new: Consistently treat fatal errors as fatal Date: Sun, 22 Apr 2012 11:50:49 -0400 Message-Id: <1335109852-10150-2-git-send-email-amdragon@mit.edu> X-Mailer: git-send-email 1.7.9.1 In-Reply-To: <1335109852-10150-1-git-send-email-amdragon@mit.edu> References: <1330357759-1337-1-git-send-email-amdragon@mit.edu> <1335109852-10150-1-git-send-email-amdragon@mit.edu> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrEIsWRmVeSWpSXmKPExsUixG6novtQY4q/waJJxhbXb85kdmD0eLbq FnMAYxSXTUpqTmZZapG+XQJXRuuJE8wF0wUrJk9uYWlg3MrbxcjJISFgIjF34RsmCFtM4sK9 9WxdjFwcQgL7GCX+zzrDBpIQEtjAKLHvnQFE4j6TxPrvE5kgnPmMEjfuTQBrZxPQkNi2fzkj iC0iIC2x8+5s1i5GDg5mATWJP10qIGFhAVeJht6XrCA2i4CqRM//yWDlvAIOEsvutbFDXKEg 8WzdcbCRnAKOEh/frWSCOKJM4tu8t+wTGPkXMDKsYpRNya3SzU3MzClOTdYtTk7My0st0jXS y80s0UtNKd3ECAoaTkneHYzvDiodYhTgYFTi4X1pMtlfiDWxrLgy9xCjJAeTkiivm9oUfyG+ pPyUyozE4oz4otKc1OJDjBIczEoivJ9FgMp5UxIrq1KL8mFS0hwsSuK8qlrv/IQE0hNLUrNT UwtSi2CyMhwcShK85sDoEBIsSk1PrUjLzClBSDNxcIIM5wEabg1Sw1tckJhbnJkOkT/FqCgl zqsMkhAASWSU5sH1wqL6FaM40CvCvCEgVTzAhADX/QpoMBPQ4ISYSSCDSxIRUlINjPK3Njru 92x4Yu0xzTak+ovBPKm2KOslBy6t9hXunJJz9fJ0ya99O1u43PTZz74y4Dze/pWpXnC1XxmX w7OSl5ob5r4qaLpvsu7hZo3zAmv6ptq+3/hTtO3WgcXRGqwPmk9N28dxuVqxTuZPe/wNXbsz Quds/6xLYI69oLZb6N3kAEtR36L3V5VYijMSDbWYi4oTAXVTbufFAgAA 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, 22 Apr 2012 15:50:59 -0000 Previously, fatal errors in add_files_recursive were not treated as fatal by its callers (including itself!). This makes add_files_recursive errors consistently fatal and updates all callers to treat them as fatal. --- notmuch-new.c | 16 ++++++++++++---- 1 files changed, 12 insertions(+), 4 deletions(-) diff --git a/notmuch-new.c b/notmuch-new.c index 4f13535..15c0b36 100644 --- a/notmuch-new.c +++ b/notmuch-new.c @@ -308,6 +308,10 @@ add_files_recursive (notmuch_database_t *notmuch, if (num_fs_entries == -1) { fprintf (stderr, "Error opening directory %s: %s\n", path, strerror (errno)); + /* We consider this a fatal error because, if a user moved a + * message from another directory that we were able to scan + * into this directory, skipping this directory will cause + * that message to be lost. */ ret = NOTMUCH_STATUS_FILE_ERROR; goto DONE; } @@ -351,8 +355,10 @@ add_files_recursive (notmuch_database_t *notmuch, next = talloc_asprintf (notmuch, "%s/%s", path, entry->d_name); status = add_files_recursive (notmuch, next, state); - if (status && ret == NOTMUCH_STATUS_SUCCESS) + if (status) { ret = status; + goto DONE; + } talloc_free (next); next = NULL; } @@ -933,6 +939,8 @@ notmuch_new_command (void *ctx, int argc, char *argv[]) } ret = add_files (notmuch, db_path, &add_files_state); + if (ret) + goto DONE; gettimeofday (&tv_start, NULL); for (f = add_files_state.removed_files->head; f && !interrupted; f = f->next) { @@ -965,6 +973,7 @@ notmuch_new_command (void *ctx, int argc, char *argv[]) } } + DONE: talloc_free (add_files_state.removed_files); talloc_free (add_files_state.removed_directories); talloc_free (add_files_state.directory_mtimes); @@ -1012,10 +1021,9 @@ notmuch_new_command (void *ctx, int argc, char *argv[]) printf ("\n"); - if (ret) { - printf ("\nNote: At least one error was encountered: %s\n", + if (ret) + printf ("\nNote: A fatal error was encountered: %s\n", notmuch_status_to_string (ret)); - } notmuch_database_close (notmuch); -- 1.7.9.1