[[!comment format=mdwn
 username="http://joeyh.name/"
 nickname="joey"
 subject="comment 9"
 date="2013-06-11T15:30:14Z"
 content="""
My guess about the write bit seems to be spot on. Which does mean it's a race, just one that happens to be easy to reproduce. It does not happen every time, but 1 time out of 10 or more often.

You can try commenting out the `preventWrite` line in `Command/Add.hs` and rebuilding to see it fix it for you too. I will need to think long and hard about how to make files be ingested safely without turning off the write bit. But, I had been meaning to work on that at some point anyway, so good to have this bug to make it happen.

I instrumented latexmk's call to `$out_handle->open` to see how it's failing:

open failed: Permission denied 256 

Which confirms the problem. It seems that it first creates the file, and then closes it, and then re-opens it to write to it some more. git-annex gets in between these two calls and messes up the permissions behind its back.
"""]]
