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 90340431FAF for ; Mon, 27 Feb 2012 07:49:29 -0800 (PST) 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 fKDS3jicJpKm for ; Mon, 27 Feb 2012 07:49:28 -0800 (PST) Received: from dmz-mailsec-scanner-1.mit.edu (DMZ-MAILSEC-SCANNER-1.MIT.EDU [18.9.25.12]) by olra.theworths.org (Postfix) with ESMTP id 98E1C431FAE for ; Mon, 27 Feb 2012 07:49:28 -0800 (PST) X-AuditID: 1209190c-b7fad6d000000920-f7-4f4ba6082378 Received: from mailhub-auth-2.mit.edu ( [18.7.62.36]) by dmz-mailsec-scanner-1.mit.edu (Symantec Messaging Gateway) with SMTP id 71.13.02336.806AB4F4; Mon, 27 Feb 2012 10:49:28 -0500 (EST) 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 q1RFnRDf000950; Mon, 27 Feb 2012 10:49:27 -0500 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 q1RFnQaN003394 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Mon, 27 Feb 2012 10:49:27 -0500 (EST) Received: from amthrax by drake.mit.edu with local (Exim 4.77) (envelope-from ) id 1S22pK-0000N9-9u; Mon, 27 Feb 2012 10:49:26 -0500 From: Austin Clements To: notmuch@notmuchmail.org Subject: [PATCH 2/3] new: Handle fatal errors in remove_filename and _remove_directory Date: Mon, 27 Feb 2012 10:49:18 -0500 Message-Id: <1330357759-1337-3-git-send-email-amdragon@mit.edu> X-Mailer: git-send-email 1.7.7.3 In-Reply-To: <1330357759-1337-1-git-send-email-amdragon@mit.edu> References: <1330357759-1337-1-git-send-email-amdragon@mit.edu> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrEIsWRmVeSWpSXmKPExsUixG6nosuxzNvf4MpWCYvrN2cyOzB6PFt1 izmAMYrLJiU1J7MstUjfLoEro2P9KsaC9xIV7/d3MDYwvhfuYuTkkBAwkVjxah8LhC0mceHe ejYQW0hgH6PEwV86XYxcQPYGRok/E84wQjj3mSTWvV4L5cxnlFh08jwzSAubgIbEtv3LGUFs EQFpiZ13Z7N2MXJwMAuoSfzpUgEJCwuESWzrvcAEYrMIqEq8fPuTFcTmFbCXOHR+JzPEFQoS 51afYwexOQUcJF6u+Qt1kb3EonNnmCcw8i9gZFjFKJuSW6Wbm5iZU5yarFucnJiXl1qka6iX m1mil5pSuokRFDSckjw7GN8cVDrEKMDBqMTDWzTL21+INbGsuDL3EKMkB5OSKK/nEqAQX1J+ SmVGYnFGfFFpTmrxIUYJDmYlEV79bKAcb0piZVVqUT5MSpqDRUmcV0XrnZ+QQHpiSWp2ampB ahFMVoaDQ0mCV2ApUKNgUWp6akVaZk4JQpqJgxNkOA/QcFOQGt7igsTc4sx0iPwpRkUpcV52 kIQASCKjNA+uFxbVrxjFgV4R5rUEqeIBJgS47ldAg5mABgdwgg0uSURISTUwcvW+Uf/dbzB5 x6oP2rM4Py960+u1UPvTy/8WE74IiXzc8f/suugrl99E3F68ac10sxkr5KN//z/JrXZo5/oC dtcIj3qVyX65+r3c772qBF/9O1L5tuvRpwPSU+snCFt++Hs6f7GcNPsKXwb5z5cXlCd+DT5t eoDdJ/9y856N8xazH/z4QuBo9golluKMREMt5qLiRAD7Oz7jxQIAAA== 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: Mon, 27 Feb 2012 15:49:29 -0000 Previously such errors were simply ignored. Now they cause an immediate cleanup and abort. --- notmuch-new.c | 24 ++++++++++++++++++------ 1 files changed, 18 insertions(+), 6 deletions(-) diff --git a/notmuch-new.c b/notmuch-new.c index bd9786a..0cbd479 100644 --- a/notmuch-new.c +++ b/notmuch-new.c @@ -780,8 +780,10 @@ remove_filename (notmuch_database_t *notmuch, add_files_state->renamed_messages++; if (add_files_state->synchronize_flags == TRUE) notmuch_message_maildir_flags_to_tags (message); - } else + status = NOTMUCH_STATUS_SUCCESS; + } else if (status == NOTMUCH_STATUS_SUCCESS) { add_files_state->removed_messages++; + } notmuch_message_destroy (message); notmuch_database_end_atomic (notmuch); return status; @@ -789,12 +791,13 @@ remove_filename (notmuch_database_t *notmuch, /* Recursively remove all filenames from the database referring to * 'path' (or to any of its children). */ -static void +static notmuch_status_t _remove_directory (void *ctx, notmuch_database_t *notmuch, const char *path, add_files_state_t *add_files_state) { + notmuch_status_t status; notmuch_directory_t *directory; notmuch_filenames_t *files, *subdirs; char *absolute; @@ -807,8 +810,10 @@ _remove_directory (void *ctx, { absolute = talloc_asprintf (ctx, "%s/%s", path, notmuch_filenames_get (files)); - remove_filename (notmuch, absolute, add_files_state); + status = remove_filename (notmuch, absolute, add_files_state); talloc_free (absolute); + if (status) + return status; } for (subdirs = notmuch_directory_get_child_directories (directory); @@ -817,11 +822,14 @@ _remove_directory (void *ctx, { absolute = talloc_asprintf (ctx, "%s/%s", path, notmuch_filenames_get (subdirs)); - _remove_directory (ctx, notmuch, absolute, add_files_state); + status = _remove_directory (ctx, notmuch, absolute, add_files_state); talloc_free (absolute); + if (status) + return status; } notmuch_directory_destroy (directory); + return NOTMUCH_STATUS_SUCCESS; } int @@ -939,7 +947,9 @@ notmuch_new_command (void *ctx, int argc, char *argv[]) gettimeofday (&tv_start, NULL); for (f = add_files_state.removed_files->head; f && !interrupted; f = f->next) { - remove_filename (notmuch, f->filename, &add_files_state); + ret = remove_filename (notmuch, f->filename, &add_files_state); + if (ret) + goto DONE; if (do_print_progress) { do_print_progress = 0; generic_print_progress ("Cleaned up", "messages", @@ -950,7 +960,9 @@ notmuch_new_command (void *ctx, int argc, char *argv[]) gettimeofday (&tv_start, NULL); for (f = add_files_state.removed_directories->head, i = 0; f && !interrupted; f = f->next, i++) { - _remove_directory (ctx, notmuch, f->filename, &add_files_state); + ret = _remove_directory (ctx, notmuch, f->filename, &add_files_state); + if (ret) + goto DONE; if (do_print_progress) { do_print_progress = 0; generic_print_progress ("Cleaned up", "directories", -- 1.7.7.3