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

Daniel Kahn Gillmor dkg at fifthhorseman.net
Tue Nov 16 07:38:20 PST 2010


On 11/16/2010 08:38 AM, Jameson Rollins wrote:
> On Tue, 16 Nov 2010 15:33:30 +0200, "Ciprian Dorin, Craciun" <ciprian.craciun at 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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 900 bytes
Desc: OpenPGP digital signature
URL: <http://notmuchmail.org/pipermail/notmuch/attachments/20101116/552d79a3/attachment.pgp>


More information about the notmuch mailing list