From 3b8f591823d68870b630fd038a710401712e2047 Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Sat, 5 Sep 2015 12:35:31 +0300 Subject: [PATCH] [PATCH 2/2] cli: reset db directory mtime upon directory removal --- dc/889d74d62c5ee54b516a6ab79336b60623a936 | 108 ++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 dc/889d74d62c5ee54b516a6ab79336b60623a936 diff --git a/dc/889d74d62c5ee54b516a6ab79336b60623a936 b/dc/889d74d62c5ee54b516a6ab79336b60623a936 new file mode 100644 index 000000000..1452b821d --- /dev/null +++ b/dc/889d74d62c5ee54b516a6ab79336b60623a936 @@ -0,0 +1,108 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by arlo.cworth.org (Postfix) with ESMTP id C53F46DE1510 + for ; Sat, 5 Sep 2015 02:35:41 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: -0.502 +X-Spam-Level: +X-Spam-Status: No, score=-0.502 tagged_above=-999 required=5 tests=[AWL=0.218, + RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01] + autolearn=disabled +Received: from arlo.cworth.org ([127.0.0.1]) + by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id gGoqPBqfY7bA for ; + Sat, 5 Sep 2015 02:35:40 -0700 (PDT) +Received: from mail-wi0-f169.google.com (mail-wi0-f169.google.com + [209.85.212.169]) + by arlo.cworth.org (Postfix) with ESMTPS id CE2216DE1502 + for ; Sat, 5 Sep 2015 02:35:39 -0700 (PDT) +Received: by wiclk2 with SMTP id lk2so38787025wic.1 + for ; Sat, 05 Sep 2015 02:35:38 -0700 (PDT) +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=1e100.net; s=20130820; + h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to + :references; + bh=5aFUv8YoQc3El441ck4fc5uHQKbvulgDow8hGbYtwrc=; + b=R5CXdX2aNmcQj/TZFQgdbyd0JKdKvHsVylpZihbPmt3/b7rwRvDoFF6LdwWLnNIcn/ + aNCjuIEiakAjLJMChSWOads9+Ktt/TQHKzAO4sq5THo38QBRkdYXu/+BJ0KJhN7bkGW6 + eVVC9zUTvVO/09Ud5FZW1kqzuow5P0yyYW0St+P5OzHtZYgIlqifZg9LyGGU4LxiiN/V + Nvuu+Meam6IslDuLVlsZm4vcn6Dx/cFt/4mYq9s3o+IIl3EbfTH9gU1jH8W2nKOmd4jx + Mli+6hnZusSFGj7h4R9dqABrXStLpCGbV0Q0JH4yVRZrxML13+8evP8vXeuFLuu6n4W6 + 94XQ== +X-Gm-Message-State: + ALoCoQnBHaHK1XgCCaOUEMF9Dglj9IFiswlhb5t5GC/mK5avGHv3DmYyEXjSx79+Soxe/9tKOtWi +X-Received: by 10.194.113.101 with SMTP id ix5mr16644944wjb.66.1441445738003; + Sat, 05 Sep 2015 02:35:38 -0700 (PDT) +Received: from localhost (mobile-access-bcee4f-131.dhcp.inet.fi. + [188.238.79.131]) + by smtp.gmail.com with ESMTPSA id cm6sm9237118wib.22.2015.09.05.02.35.37 + (version=TLSv1/SSLv3 cipher=OTHER); + Sat, 05 Sep 2015 02:35:37 -0700 (PDT) +From: Jani Nikula +To: Mark Walters , + notmuch@notmuchmail.org +Subject: [PATCH 2/2] cli: reset db directory mtime upon directory removal +Date: Sat, 5 Sep 2015 12:35:31 +0300 +Message-Id: <1441445731-4362-2-git-send-email-jani@nikula.org> +X-Mailer: git-send-email 2.1.4 +In-Reply-To: <1441445731-4362-1-git-send-email-jani@nikula.org> +References: <87siray6th.fsf@qmul.ac.uk> + <1441445731-4362-1-git-send-email-jani@nikula.org> +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.18 +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, 05 Sep 2015 09:35:41 -0000 + +The library does not have a function to remove a directory document +for a path. Usually this doesn't matter except for a slight waste of +space. However, if the same directory gets added to the filesystem +again, the old directory document is found with the old mtime. Reset +the directory mtime on removal to avoid problems. + +The corner case that can hit this problem is renaming directories back +and forth. Renaming does not change the mtime of the directory in the +filesystem, and thus the old db directory document mtime may match the +fs mtime of the directory. + +The long term fix might be to add a library function to remove a +directory document, however this is a much simpler and faster fix for +the time being. +--- + notmuch-new.c | 9 +++++++++ + 1 file changed, 9 insertions(+) + +diff --git a/notmuch-new.c b/notmuch-new.c +index 514e06a4d1f3..33645349cd5f 100644 +--- a/notmuch-new.c ++++ b/notmuch-new.c +@@ -878,6 +878,15 @@ _remove_directory (void *ctx, + goto DONE; + } + ++ /* ++ * XXX: The library does not have a function to remove a directory ++ * document for a path. Usually this doesn't matter except for a ++ * slight waste of space. However, if the directory gets added to ++ * the filesystem again, the old directory document is found with ++ * the old mtime. Reset the directory mtime to avoid problems. ++ */ ++ notmuch_directory_set_mtime (directory, 0); ++ + DONE: + notmuch_directory_destroy (directory); + return status; +-- +2.1.4 + -- 2.26.2