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 C8993429E2B for ; Sat, 11 Jun 2011 13:07:16 -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 oqxs4Q8xQ7B6 for ; Sat, 11 Jun 2011 13:07:16 -0700 (PDT) Received: from dmz-mailsec-scanner-6.mit.edu (DMZ-MAILSEC-SCANNER-6.MIT.EDU [18.7.68.35]) by olra.theworths.org (Postfix) with ESMTP id 20047431FB6 for ; Sat, 11 Jun 2011 13:07:16 -0700 (PDT) X-AuditID: 12074423-b7ce8ae000000a29-a1-4df3caee0342 Received: from mailhub-auth-4.mit.edu ( [18.7.62.39]) by dmz-mailsec-scanner-6.mit.edu (Symantec Messaging Gateway) with SMTP id 8F.55.02601.EEAC3FD4; Sat, 11 Jun 2011 16:07:10 -0400 (EDT) Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id p5BK7FFM030040; Sat, 11 Jun 2011 16:07:15 -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 p5BK7ELE006044 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Sat, 11 Jun 2011 16:07:15 -0400 (EDT) Received: from amthrax by drake.mit.edu with local (Exim 4.76) (envelope-from ) id 1QVUSg-0000IY-CZ; Sat, 11 Jun 2011 16:07:14 -0400 From: Austin Clements To: notmuch@notmuchmail.org Subject: [PATCH 13/17] new: Cleanup. Put removed/renamed message count in add_files_state_t. Date: Sat, 11 Jun 2011 16:04:39 -0400 Message-Id: <1307822683-848-14-git-send-email-amdragon@mit.edu> X-Mailer: git-send-email 1.7.5.1 In-Reply-To: <1307822683-848-1-git-send-email-amdragon@mit.edu> References: <87ei34rnc5.fsf@yoom.home.cworth.org> <1307822683-848-1-git-send-email-amdragon@mit.edu> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrMIsWRmVeSWpSXmKPExsUixG6nrvvu1Gdfg4lnTC2u35zJ7MDo8WzV LeYAxigum5TUnMyy1CJ9uwSujFt31jIV3FGqOPbsAWMD4z7pLkZODgkBE4l9N6eyQdhiEhfu rQezhQT2MUrceSTaxcgFZG9glNj/YyYrhHOfSeL7v21QVfMZJebPlwex2QQ0JLbtX84IYosI SEvsvDsbqIGDg1lATeJPlwpIWFggVuLatz1MIDaLgKrEv0372UFsXgF7ibknj7FCHKEgceXK PBYQmxMoPu/gVRaIVWkSS27tZp/AyL+AkWEVo2xKbpVubmJmTnFqsm5xcmJeXmqRrplebmaJ XmpK6SZGcMi4KO9g/HNQ6RCjAAejEg+v4trPvkKsiWXFlbmHGCU5mJREeXVOAIX4kvJTKjMS izPii0pzUosPMUpwMCuJ8K5v/+QrxJuSWFmVWpQPk5LmYFES550rqe4rJJCeWJKanZpakFoE k5Xh4FCS4JUExoaQYFFqempFWmZOCUKaiYMTZDgP0PCjJ4FqeIsLEnOLM9Mh8qcYjTkeb9h0 iJGjfTOQFGLJy89LlRLnVQcZJwBSmlGaBzcNFvevGMWBnhPm/QEykAeYMuDmvQJaxQS0SqAU bFVJIkJKqoFRtOHxgY9ZvoLBOxbKcBvKKJZP3FDpGbDxe5a9gEWTzB/noPPCqXN4rmvIPvtQ tm1S3KKKl5GWyQek7RzePfM9F70n4eVx9Yyv+hmst87uveBt01SveOEtM8sied8nbk5rZD4Y LdJ+sOjX7mDXX9eXXuEKcNUxm3Fw2lzTlU8ipCfUmt/+Gq+sxFKckWioxVxUnAgAIqG+ytYC AAA= Cc: Austin Clements 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: Sat, 11 Jun 2011 20:07:17 -0000 Previously, pointers to these variables were passed around individually. This was okay when only one function needed them, but we're about to need them in a few more places. --- notmuch-new.c | 36 ++++++++++++++++-------------------- 1 files changed, 16 insertions(+), 20 deletions(-) diff --git a/notmuch-new.c b/notmuch-new.c index d1bea55..cdc8a1c 100644 --- a/notmuch-new.c +++ b/notmuch-new.c @@ -42,7 +42,7 @@ typedef struct { int total_files; int processed_files; - int added_messages; + int added_messages, removed_messages, renamed_messages; struct timeval tv_start; _filename_list_t *removed_files; @@ -702,8 +702,7 @@ static void _remove_directory (void *ctx, notmuch_database_t *notmuch, const char *path, - int *renamed_files, - int *removed_files) + add_files_state_t *add_files_state) { notmuch_directory_t *directory; notmuch_filenames_t *files, *subdirs; @@ -720,9 +719,9 @@ _remove_directory (void *ctx, notmuch_filenames_get (files)); status = notmuch_database_remove_message (notmuch, absolute); if (status == NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID) - *renamed_files = *renamed_files + 1; + add_files_state->renamed_messages++; else - *removed_files = *removed_files + 1; + add_files_state->removed_messages++; talloc_free (absolute); } @@ -732,7 +731,7 @@ _remove_directory (void *ctx, { absolute = talloc_asprintf (ctx, "%s/%s", path, notmuch_filenames_get (subdirs)); - _remove_directory (ctx, notmuch, absolute, renamed_files, removed_files); + _remove_directory (ctx, notmuch, absolute, add_files_state); talloc_free (absolute); } @@ -753,7 +752,6 @@ notmuch_new_command (void *ctx, int argc, char *argv[]) char *dot_notmuch_path; struct sigaction action; _filename_node_t *f; - int renamed_files, removed_files; notmuch_status_t status; int i; notmuch_bool_t timer_is_active = FALSE; @@ -826,6 +824,7 @@ notmuch_new_command (void *ctx, int argc, char *argv[]) add_files_state.processed_files = 0; add_files_state.added_messages = 0; + add_files_state.removed_messages = add_files_state.renamed_messages = 0; gettimeofday (&add_files_state.tv_start, NULL); add_files_state.removed_files = _filename_list_create (ctx); @@ -840,27 +839,24 @@ notmuch_new_command (void *ctx, int argc, char *argv[]) ret = add_files (notmuch, db_path, &add_files_state); - removed_files = 0; - renamed_files = 0; gettimeofday (&tv_start, NULL); for (f = add_files_state.removed_files->head; f && !interrupted; f = f->next) { status = notmuch_database_remove_message (notmuch, f->filename); if (status == NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID) - renamed_files++; + add_files_state.renamed_messages++; else - removed_files++; + add_files_state.removed_messages++; if (do_print_progress) { do_print_progress = 0; generic_print_progress ("Cleaned up", "messages", - tv_start, removed_files + renamed_files, + tv_start, add_files_state.removed_messages + add_files_state.renamed_messages, add_files_state.removed_files->count); } } 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, - &renamed_files, &removed_files); + _remove_directory (ctx, notmuch, f->filename, &add_files_state); if (do_print_progress) { do_print_progress = 0; generic_print_progress ("Cleaned up", "directories", @@ -937,16 +933,16 @@ notmuch_new_command (void *ctx, int argc, char *argv[]) printf ("No new mail."); } - if (removed_files) { + if (add_files_state.removed_messages) { printf (" Removed %d %s.", - removed_files, - removed_files == 1 ? "message" : "messages"); + add_files_state.removed_messages, + add_files_state.removed_messages == 1 ? "message" : "messages"); } - if (renamed_files) { + if (add_files_state.renamed_messages) { printf (" Detected %d file %s.", - renamed_files, - renamed_files == 1 ? "rename" : "renames"); + add_files_state.renamed_messages, + add_files_state.renamed_messages == 1 ? "rename" : "renames"); } printf ("\n"); -- 1.7.5.1