From 3685a71ef0c42be310e10b3be3694092775034a0 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Sat, 19 May 2012 00:13:38 +2000 Subject: [PATCH] [PATCH 5/9] new: Remove workaround for detecting newly created directory objects --- b5/39c817101dedc059ba81767cf48fde413f47cd | 154 ++++++++++++++++++++++ 1 file changed, 154 insertions(+) create mode 100644 b5/39c817101dedc059ba81767cf48fde413f47cd diff --git a/b5/39c817101dedc059ba81767cf48fde413f47cd b/b5/39c817101dedc059ba81767cf48fde413f47cd new file mode 100644 index 000000000..617c69562 --- /dev/null +++ b/b5/39c817101dedc059ba81767cf48fde413f47cd @@ -0,0 +1,154 @@ +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 1D91B429E36 + for ; Thu, 17 May 2012 21:14:00 -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 i0e7ZYrcKgjs for ; + Thu, 17 May 2012 21:13:58 -0700 (PDT) +Received: from dmz-mailsec-scanner-4.mit.edu (DMZ-MAILSEC-SCANNER-4.MIT.EDU + [18.9.25.15]) + by olra.theworths.org (Postfix) with ESMTP id 7729A429E25 + for ; Thu, 17 May 2012 21:13:53 -0700 (PDT) +X-AuditID: 1209190f-b7f4f6d00000092b-3f-4fb5cc8052dc +Received: from mailhub-auth-1.mit.edu ( [18.9.21.35]) + by dmz-mailsec-scanner-4.mit.edu (Symantec Messaging Gateway) with SMTP + id 38.3A.02347.08CC5BF4; Fri, 18 May 2012 00:13:52 -0400 (EDT) +Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) + by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id q4I4DqQN029944; + Fri, 18 May 2012 00:13:52 -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 q4I4DoPQ026788 + (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); + Fri, 18 May 2012 00:13:51 -0400 (EDT) +Received: from amthrax by drake.mit.edu with local (Exim 4.77) + (envelope-from ) + id 1SVEZa-0000z9-Io; Fri, 18 May 2012 00:13:50 -0400 +From: Austin Clements +To: notmuch@notmuchmail.org +Subject: [PATCH 5/9] new: Remove workaround for detecting newly created + directory objects +Date: Fri, 18 May 2012 00:13:38 -0400 +Message-Id: <1337314423-3702-6-git-send-email-amdragon@mit.edu> +X-Mailer: git-send-email 1.7.10 +In-Reply-To: <1337314423-3702-1-git-send-email-amdragon@mit.edu> +References: <1337314423-3702-1-git-send-email-amdragon@mit.edu> +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFtrEIsWRmVeSWpSXmKPExsUixCmqrNtwZqu/weFvphbXb85kdmD0eLbq + FnMAYxSXTUpqTmZZapG+XQJXxrMvzcwFp6QrJj08wtrAOFu0i5GTQ0LARGLruSssELaYxIV7 + 69m6GLk4hAT2MUqcbP3PCOFsYJRomjmZGcK5zySxdP0zFghnFqPEwpd9TCD9bAIaEtv2L2cE + sUUEpCV23p3N2sXIwcEsoCbxp0sFJCwsEClx89csZhCbRUBVovPVTVYQm1fAXuL/pmtQZ8hL + PL3fxwbSyingIDHteDRIWAio5N+FZpYJjPwLGBlWMcqm5Fbp5iZm5hSnJusWJyfm5aUW6Zro + 5WaW6KWmlG5iBAeNJP8Oxm8HlQ4xCnAwKvHw7piz1V+INbGsuDL3EKMkB5OSKO/3k0AhvqT8 + lMqMxOKM+KLSnNTiQ4wSHMxKIryy3UA53pTEyqrUonyYlDQHi5I4r5rWOz8hgfTEktTs1NSC + 1CKYrAwHh5IEr8VpoEbBotT01Iq0zJwShDQTByfIcB6g4VogNbzFBYm5xZnpEPlTjIpS4rw2 + IAkBkERGaR5cLyyqXzGKA70izBsKUsUDTAhw3a+ABjMBDS7L3QQyuCQRISXVwNiqb80Q17g1 + Zf3xqetm/Qtgn9wx1UdDrDhi2d39Ktue6oT+nNruM+Pa7xmHvs0KSHado/f02iTThWGi8zYl + uW0/cue608cnUc83TpueaL/0xOlkw/KVvns8FdPeNopLalx7YLZp85z9W+avm/2698jb789W + LMy5GL9QWFjlYcqrfZ8e3rjc3X7gmhJLcUaioRZzUXEiACrcEnbFAgAA +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: Fri, 18 May 2012 04:14:00 -0000 + +Previously, notmuch_database_get_directory did not indicate whether or +not the returned directory object was newly created, which required a +workaround to distinguish newly created directory objects with no +child messages from directory objects that had no mtime set but did +have child messages. Now that notmuch_database_get_directory +distinguishes whether or not the directory object exists in the +database, this workaround is no longer necessary. +--- + notmuch-new.c | 36 +++++++----------------------------- + 1 file changed, 7 insertions(+), 29 deletions(-) + +diff --git a/notmuch-new.c b/notmuch-new.c +index a3a8bec..72dd558 100644 +--- a/notmuch-new.c ++++ b/notmuch-new.c +@@ -256,7 +256,7 @@ add_files_recursive (notmuch_database_t *notmuch, + notmuch_filenames_t *db_subdirs = NULL; + time_t stat_time; + struct stat st; +- notmuch_bool_t is_maildir, new_directory; ++ notmuch_bool_t is_maildir; + const char **tag; + + if (stat (path, &st)) { +@@ -281,33 +281,12 @@ add_files_recursive (notmuch_database_t *notmuch, + } + db_mtime = directory ? notmuch_directory_get_mtime (directory) : 0; + +- new_directory = db_mtime ? FALSE : TRUE; +- +- /* XXX This is a temporary workaround. If we don't update the +- * database mtime until after processing messages in this +- * directory, then a 0 mtime is *not* sufficient to indicate that +- * this directory has no messages or subdirs in the database (for +- * example, if an earlier run skipped the mtime update because +- * fs_mtime == stat_time, or was interrupted before updating the +- * mtime at the end). To address this, we record a (bogus) +- * non-zero value before processing any child messages so that a +- * later run won't mistake this for a new directory (and, for +- * example, fail to detect removed files and subdirs). +- * +- * A better solution would be for notmuch_database_get_directory +- * to indicate if it really created a new directory or not, either +- * by a new out-argument, or by recording this information and +- * providing an accessor. +- */ +- if (new_directory && directory) +- notmuch_directory_set_mtime (directory, -1); +- + /* If the database knows about this directory, then we sort based + * on strcmp to match the database sorting. Otherwise, we can do + * inode-based sorting for faster filesystem operation. */ + num_fs_entries = scandir (path, &fs_entries, 0, +- new_directory ? +- dirent_sort_inode : dirent_sort_strcmp_name); ++ directory ? ++ dirent_sort_strcmp_name : dirent_sort_inode); + + if (num_fs_entries == -1) { + fprintf (stderr, "Error opening directory %s: %s\n", +@@ -376,13 +355,12 @@ add_files_recursive (notmuch_database_t *notmuch, + * being discovered until the clock catches up and the directory + * is modified again). + */ +- if (fs_mtime == db_mtime) ++ if (directory && fs_mtime == db_mtime) + goto DONE; + +- /* new_directory means a directory that the database has never +- * seen before. In that case, we can simply leave db_files and +- * db_subdirs NULL. */ +- if (!new_directory) { ++ /* If the database has never seen this directory before, we can ++ * simply leave db_files and db_subdirs NULL. */ ++ if (directory) { + db_files = notmuch_directory_get_child_files (directory); + db_subdirs = notmuch_directory_get_child_directories (directory); + } +-- +1.7.10 + -- 2.26.2