From: Peter Wang <novalazy@gmail.com>
To: Mark Walters <markwalters1009@gmail.com>
Cc: notmuch@notmuchmail.org
Subject: Re: [PATCH 05/18] insert: move file from Maildir tmp to new
Date: Mon, 19 Nov 2012 23:26:51 +1100 [thread overview]
Message-ID: <20121119232651.GB2063@hili.localdomain> (raw)
In-Reply-To: <87haomq0hx.fsf@qmul.ac.uk>
On Sun, 18 Nov 2012 17:33:46 +0000, Mark Walters <markwalters1009@gmail.com> wrote:
> On Wed, 25 Jul 2012, Peter Wang <novalazy@gmail.com> 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.
Peter
[1]: http://wiki.dovecot.org/MailboxFormat/Maildir#Mail_delivery
next prev parent reply other threads:[~2012-11-19 12:26 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-25 13:42 [PATCH 01/18] cli: add stub for insert command Peter Wang
2012-07-25 13:42 ` [PATCH 02/18] insert: open database Peter Wang
2012-07-25 13:42 ` [PATCH 03/18] insert: open Maildir tmp file Peter Wang
2012-11-18 15:47 ` Mark Walters
2012-07-25 13:42 ` [PATCH 04/18] insert: copy stdin to " Peter Wang
2012-11-26 16:21 ` Ali Polatel
2012-07-25 13:42 ` [PATCH 05/18] insert: move file from Maildir tmp to new Peter Wang
2012-11-18 17:33 ` Mark Walters
2012-11-19 12:26 ` Peter Wang [this message]
2012-11-19 13:49 ` Mark Walters
2012-07-25 13:42 ` [PATCH 06/18] insert: add new message to database Peter Wang
2012-11-18 17:00 ` Mark Walters
2012-07-25 13:42 ` [PATCH 07/18] insert: add --folder option Peter Wang
2012-07-25 13:42 ` [PATCH 08/18] insert: check folder name Peter Wang
2012-07-25 13:42 ` [PATCH 09/18] insert: apply default tags to new message Peter Wang
2012-07-25 13:42 ` [PATCH 10/18] insert: parse command-line tag operations Peter Wang
2012-11-18 17:05 ` Mark Walters
2012-07-25 13:42 ` [PATCH 11/18] insert: apply " Peter Wang
2012-07-25 13:42 ` [PATCH 12/18] insert: add copyright line from notmuch-deliver Peter Wang
2012-07-25 13:42 ` [PATCH 13/18] test: add tests for insert Peter Wang
2012-07-25 13:42 ` [PATCH 14/18] man: document 'insert' command Peter Wang
2012-11-18 17:13 ` Mark Walters
2012-07-25 13:42 ` [PATCH 15/18] man: reference notmuch-insert.1 Peter Wang
2012-07-25 13:42 ` [PATCH 16/18] insert: add --create-folder option Peter Wang
2012-11-18 17:24 ` Mark Walters
2012-07-25 13:42 ` [PATCH 17/18] man: document insert " Peter Wang
2012-07-25 13:42 ` [PATCH 18/18] test: test insert --create-folder Peter Wang
2012-07-25 17:11 ` [PATCH 01/18] cli: add stub for insert command Jameson Graef Rollins
2012-07-26 0:49 ` Peter Wang
2012-11-19 12:15 ` David Bremner
2012-11-18 17:35 ` Mark Walters
2012-11-19 12:34 ` Peter Wang
2012-11-19 13:52 ` Mark Walters
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20121119232651.GB2063@hili.localdomain \
--to=novalazy@gmail.com \
--cc=markwalters1009@gmail.com \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).