From: Chris Wedgwood Date: Tue, 03 May 2005 19:27:53 GMT Subject: Re: Careful object writing.. Message-ID: <20050503192753.GA6435@taniwha.stupidest.org> In-Reply-To: On Tue, May 03, 2005 at 12:15:08PM -0700, Linus Torvalds wrote: > So now I do it "right", and create a temporary file in the "top" > object directory, and then when it's all done, I do a "link()" to > the final place and unlink the original. how is this better than a single rename? i take it there is something fundamental from clue.101 i slept though here? also, if you are *really* paranoid you want to fsync *before* you do the link/unklink or rename --- which is what MTAs do[1] however, that said it *kills* performance and if it's not critical it's really a terrible idea also, shouldn't HEAD (and similar)[2] be updated with a temporary and a rename too? > I also change the permission to 0444 before it gets its final name. cool > NOTE NOTE NOTE! I have _not_ updated all the helper stuff that also > write objects. i thought this was all common code? if it's not maybe now is the time to change that? [1] yes, i know this depends on the fs used and various things and ext3 should be fine, blah blah blah, but not everyone uses ext3 and quite probably not everyone will use git under Linux [2] i didn't check the code as i'm still using BK in places