[MERGE] Knit Index should ignore empty files

John Arbash Meinel john at arbash-meinel.com
Thu Dec 7 23:27:02 GMT 2006


There is a very small race condition while creating a new .knit file.
Where we have to open the file, and then write the header. For
performance reasons we are using put_non_atomic (or append), rather than
writing to a temp file and renaming it into place.

The window is very, very small, but it is possible to ^C during a branch
operation, and have it leave an empty .kndx file lying on disk. Earlier
versions of bzr probably suffered from it more than the current version,
but either way it is still infinitesimally possible.

The attached patch just changes the knit index code, so that if it sees
an empty .kndx file, it just treats it as though it doesn't exist. Which
lets bzr continue, rather than failing and making people feel like their
data has been corrupted.

If we decide not to accept the whole patch, I would at least like to ask
that we accept the changes to the error class, so that when this error
occurs, it is possible to investigate, and figure out what file needs to
be changed rather than giving a semi-useless error.

Also, should KnitError be considered an 'InternalError' so it gives a
traceback? It is sort of an environmental error, so I'm okay leaving it
as a short-error. But it is serious enough that a traceback might be
warranted.

John
=:->
-------------- next part --------------
A non-text attachment was scrubbed...
Name: knit-ignore-empty-files.patch
Type: text/x-patch
Size: 3854 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20061207/fe2a188f/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 254 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20061207/fe2a188f/attachment.pgp 


More information about the bazaar mailing list