Please sign in to comment.
make object writes atomic
When Grit writes a loose object via the LooseStorage class, it just opens the object file and starts writing. This works most of the time, but can be a problem in some corner cases, including: 1. If another process tries to write the same object simultaneously, the writes may be interleaved and the object can be corrupted. 2. If another process tries to read the object simultaneously, it may see the object in a half-written state. 3. If the process or machine crashes during the write, we may leave a half-written corrupt object. This can be solved by writing the object to a temporary file and linking it into place. This is the same strategy used by git itself.
- Loading branch information...