Re: `notmuch setup` replaces `~/.notmuch-config` instead of truncating it

Subject: Re: `notmuch setup` replaces `~/.notmuch-config` instead of truncating it

Date: Tue, 16 Nov 2010 10:38:20 -0500

To: Jameson Rollins

Cc: notmuch@notmuchmail.org

From: Daniel Kahn Gillmor


On 11/16/2010 08:38 AM, Jameson Rollins wrote:
> On Tue, 16 Nov 2010 15:33:30 +0200, "Ciprian Dorin, Craciun" <ciprian.craciun@gmail.com> wrote:
>>     So my question is: is this behaviour (of deleting the file and
>> creating a new one) deliberate? If not, could it be fixed (I could
>> provide a patch) to just update the file in place?
> 
> Hi, Ciprian.  I had not noticed this, but now that you mention it, I see
> that the same thing happened to me.  This behavior is surely not
> deliberate, and is definitely undesirable.  A patch would be welcome.

It often is desirable to do a replacement instead of truncation or
appending -- atomic replacement guarantees that a legitimate copy is
always available.  It eliminates a window of time when the config file
would be in an intermediate state.  Readers of the file always get
either the old state or the new state -- nothing in between.

However, you can address both concerns by detecting whether
~/.notmuch-config is a symlink and readlink()ing until you get to the
underlying file.  Then atomically replace the target instead of the
symlink itself.

	--dkg

signature.asc (application/pgp-signature)

Thread: