I guess there could be a race if you are compiling on one thread and fetching new code on another.

I'm not sure I really want to use the thread_index (and multiple copies of the repo) to fix though. An alternative might be to use locks, (especially if we are not updating EVERY compilation, only every N minutes)