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 34C74429E35 for ; Sat, 11 Jun 2011 13:06:06 -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 sbvJFx2la6Vm for ; Sat, 11 Jun 2011 13:06:05 -0700 (PDT) Received: from dmz-mailsec-scanner-5.mit.edu (DMZ-MAILSEC-SCANNER-5.MIT.EDU [18.7.68.34]) by olra.theworths.org (Postfix) with ESMTP id 4BC0A429E34 for ; Sat, 11 Jun 2011 13:06:05 -0700 (PDT) X-AuditID: 12074422-b7b0eae000007f48-aa-4df3cab18636 Received: from mailhub-auth-2.mit.edu ( [18.7.62.36]) by dmz-mailsec-scanner-5.mit.edu (Symantec Messaging Gateway) with SMTP id AA.F8.32584.1BAC3FD4; Sat, 11 Jun 2011 16:06:09 -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 p5BK64eb030810; Sat, 11 Jun 2011 16:06:04 -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 p5BK63En005922 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Sat, 11 Jun 2011 16:06:04 -0400 (EDT) Received: from amthrax by drake.mit.edu with local (Exim 4.76) (envelope-from ) id 1QVURX-0000I5-Ag; Sat, 11 Jun 2011 16:06:03 -0400 From: Austin Clements To: notmuch@notmuchmail.org Subject: [PATCH 06/17] new: Defer updating directory mtimes until the end. Date: Sat, 11 Jun 2011 16:04:32 -0400 Message-Id: <1307822683-848-7-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+NgFtrHIsWRmVeSWpSXmKPExsUixG6norvx1GdfgxPr9Syu35zJ7MDo8WzV LeYAxigum5TUnMyy1CJ9uwSujJb3AgXnxSp23PvG1MD4V7CLkZNDQsBE4uqmvcwQtpjEhXvr 2boYuTiEBPYxSvxbPIsVwtnAKDHh/0WozH0miTXXG5kgnPmMEpt/f2IH6WcT0JDYtn85I4gt IiAtsfPubKB2Dg5mATWJP10qIGFhAS+JrgUTwEpYBFQlVm74B7aaV8BO4tKNdawQZyhIXLky jwXE5hSwl5h38CqYLSSQJrHk1m72CYz8CxgZVjHKpuRW6eYmZuYUpybrFicn5uWlFuma6uVm luilppRuYgQHjYvSDsafB5UOMQpwMCrx8Cqu/ewrxJpYVlyZe4hRkoNJSZRX5wRQiC8pP6Uy I7E4I76oNCe1+BCjBAezkgjv+vZPvkK8KYmVValF+TApaQ4WJXHeOZLqvkIC6YklqdmpqQWp RTBZGQ4OJQleSWB0CAkWpaanVqRl5pQgpJk4OEGG8wANP3oSqIa3uCAxtzgzHSJ/ilGX4/GG TYcYhVjy8vNSpcR574MUCYAUZZTmwc2BRfsrRnGgt4R5f4BU8QATBdykV0BLmICWCJSCLSlJ REhJNTDW8TP9+XRCh23V0Tmd9jkWb9dp1LUsSj/5XyCVhcvsxEPVrRy6aUFifpO//fr2oW+Z VvcDPrW/+194h+VsKFHz/MaSxc4X/XdKq5z6I9vpq3ik9+wrn8gifnHy/hOJvK+4e7LUD12J njHv0vu3d/aIiHsfWLzm+2Uv3hCHvLDYYLZ/Qhc4hGSVWIozEg21mIuKEwG5ULlt0QIAAA== 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:06:06 -0000 Previously, if notmuch new were interrupted between updating the directory mtime and handling removals from that directory, a subsequent notmuch new would not handle those removals until something else changed in that directory. This defers recording the updated mtime until after removals are handled to eliminate this problem. --- notmuch-new.c | 23 +++++++++++++++++------ 1 files changed, 17 insertions(+), 6 deletions(-) diff --git a/notmuch-new.c b/notmuch-new.c index 6859594..b76b608 100644 --- a/notmuch-new.c +++ b/notmuch-new.c @@ -24,6 +24,7 @@ typedef struct _filename_node { char *filename; + time_t mtime; struct _filename_node *next; } _filename_node_t; @@ -46,6 +47,7 @@ typedef struct { _filename_list_t *removed_files; _filename_list_t *removed_directories; + _filename_list_t *directory_mtimes; notmuch_bool_t synchronize_flags; _filename_list_t *message_ids_to_sync; @@ -86,7 +88,7 @@ _filename_list_create (const void *ctx) return list; } -static void +static _filename_node_t * _filename_list_add (_filename_list_t *list, const char *filename) { @@ -99,6 +101,8 @@ _filename_list_add (_filename_list_t *list, *(list->tail) = node; list->tail = &node->next; + + return node; } static void @@ -509,11 +513,7 @@ add_files_recursive (notmuch_database_t *notmuch, notmuch_filenames_move_to_next (db_subdirs); } - if (! interrupted) { - status = notmuch_directory_set_mtime (directory, fs_mtime); - if (status && ret == NOTMUCH_STATUS_SUCCESS) - ret = status; - } + _filename_list_add (state->directory_mtimes, path)->mtime = fs_mtime; DONE: if (next) @@ -829,6 +829,7 @@ notmuch_new_command (void *ctx, int argc, char *argv[]) add_files_state.removed_files = _filename_list_create (ctx); add_files_state.removed_directories = _filename_list_create (ctx); + add_files_state.directory_mtimes = _filename_list_create (ctx); if (! debugger_is_active () && add_files_state.output_is_a_tty && ! add_files_state.verbose) { @@ -867,8 +868,18 @@ notmuch_new_command (void *ctx, int argc, char *argv[]) } } + for (f = add_files_state.directory_mtimes->head; f && !interrupted; f = f->next) { + notmuch_directory_t *directory; + directory = notmuch_database_get_directory (notmuch, f->filename); + if (directory) { + notmuch_directory_set_mtime (directory, f->mtime); + notmuch_directory_destroy (directory); + } + } + talloc_free (add_files_state.removed_files); talloc_free (add_files_state.removed_directories); + talloc_free (add_files_state.directory_mtimes); /* Now that removals are done (hence the database is aware of all * renames), we can synchronize maildir_flags to tags for all -- 1.7.5.1