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 8FD90431FC0 for ; Mon, 19 Nov 2012 05:49:19 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -1.098 X-Spam-Level: X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5 tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001, NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] 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 OuKFUkF8F2Tt for ; Mon, 19 Nov 2012 05:49:18 -0800 (PST) Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 83905431FBC for ; Mon, 19 Nov 2012 05:49:18 -0800 (PST) Received: from smtp.qmul.ac.uk ([138.37.6.40]) by mail2.qmul.ac.uk with esmtp (Exim 4.71) (envelope-from ) id 1TaRil-0001PR-Lr; Mon, 19 Nov 2012 13:49:12 +0000 Received: from 93-97-24-31.zone5.bethere.co.uk ([93.97.24.31] helo=localhost) by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69) (envelope-from ) id 1TaRil-00075M-Be; Mon, 19 Nov 2012 13:49:07 +0000 From: Mark Walters To: Peter Wang Subject: Re: [PATCH 05/18] insert: move file from Maildir tmp to new In-Reply-To: <20121119232651.GB2063@hili.localdomain> References: <1343223767-9812-1-git-send-email-novalazy@gmail.com> <1343223767-9812-5-git-send-email-novalazy@gmail.com> <87haomq0hx.fsf@qmul.ac.uk> <20121119232651.GB2063@hili.localdomain> User-Agent: Notmuch/0.14+81~g9730584 (http://notmuchmail.org) Emacs/23.4.1 (x86_64-pc-linux-gnu) Date: Mon, 19 Nov 2012 13:49:05 +0000 Message-ID: <874nklpusu.fsf@qmul.ac.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Sender-Host-Address: 93.97.24.31 X-QM-SPAM-Info: Sender has good ham record. :) X-QM-Body-MD5: 59b428e578dce949411df32e677a0de0 (of first 20000 bytes) X-SpamAssassin-Score: -1.8 X-SpamAssassin-SpamBar: - X-SpamAssassin-Report: The QM spam filters have analysed this message to determine if it is spam. We require at least 5.0 points to mark a message as spam. This message scored -1.8 points. Summary of the scoring: * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, * medium trust * [138.37.6.40 listed in list.dnswl.org] * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider * (markwalters1009[at]gmail.com) * 0.5 AWL AWL: From: address is in the auto white-list X-QM-Scan-Virus: ClamAV says the message is clean Cc: notmuch@notmuchmail.org 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, 19 Nov 2012 13:49:19 -0000 Hi On Mon, 19 Nov 2012, Peter Wang wrote: > On Sun, 18 Nov 2012 17:33:46 +0000, Mark Walters wrote: >> On Wed, 25 Jul 2012, Peter Wang wrote: >> > Atomically move the new message file from the Maildir 'tmp' directory >> > to 'new'. >> > --- >> > notmuch-insert.c | 18 ++++++++++++++++++ >> > 1 files changed, 18 insertions(+), 0 deletions(-) >> > >> > diff --git a/notmuch-insert.c b/notmuch-insert.c >> > index 340f7e4..bab1fed 100644 >> > --- a/notmuch-insert.c >> > +++ b/notmuch-insert.c >> > @@ -75,6 +75,20 @@ maildir_open_tmp (void *ctx, const char *dir, char **tmppath, char **newpath) >> > } >> > >> > static notmuch_bool_t >> > +maildir_move_to_new (const char *tmppath, const char *newpath) >> > +{ >> > + /* We follow the Dovecot recommendation to simply use rename() >> > + * instead of link() and unlink(). >> > + */ >> > + if (rename (tmppath, newpath) == 0) { >> > + return TRUE; >> > + } >> >> Do we want to overwrite an existing message with this name? As far as I >> can see rename does overwrite and link would not: was that why rename is >> better than link/unlink? >> >> I would prefer not to overwrite but maybe there is a reason we need to. >> Would a possible alternative be to loop when finding a tmp file until >> both the tmp file and the new file do not exist? > > According to [1] it's all pointless -- just generate unique file names. > > The dovecot maildir-save.c has this comment: > > /* maildir spec says we should use link() + unlink() here. however > since our filename is guaranteed to be unique, rename() works just > as well, except faster. even if the filename wasn't unique, the > problem could still happen if the file was already moved from > new/ to cur/, so link() doesn't really provide any safety anyway. > > Besides the small temporary performance benefits, this rename() is > almost required with OSX's HFS+ filesystem, since it implements > hard links in a pretty ugly way, which makes the performance crawl > when a lot of hard links are used. */ > > Well, that's one point of view. I can't say I know any better. I think I agree with you/them. Indeed, since files in cur can have maildir flags we could find that this rename works but then the new file gets stomped on by notmuch_message_tags_to_maildir_flags which also uses rename. It might be work adding the link to [1] in the comment, but in any case I am happy with this now. Best wishes Mark > > Peter > > [1]: http://wiki.dovecot.org/MailboxFormat/Maildir#Mail_delivery