Unify logging a transaction's operations and files
The TransactionManager stores the state of a log entry in two locations:
- The protobuf message in the database.
- The files on the disk.
This is mostly due to a historical reason. Initially we didn't have mechanism to log files. The log entry was completely self-contained in the protobuf message and it was easier to store it in the database. When we started supporting logging packfiles, we wanted to log them without copying them as they could be very large. They are thus committed by just moving them to a correct location on the filesystem.
Splitting the state makes things more complex than they have to be:
- It is more complex, and thus difficult to understand. It's been a topic of confusion already a few times that the log entry's are not entirely contained in the same place.
- Committing the log changes atomically requires additional work.
- We need to handle cases where committing the protobuf message works but committing the files didn't.
- We need to handle cases where removing the protobuf message worked but committing the files didn't.
Let's simplify by committing the protobuf message in the directory as well as a file. That way the entire log entry is committed atomically by just moving the directory into the log.