Flush idx_map (msync()) before closing it, since it doesn't look like
POSIX guarantees that a matching FILE* (i.e. idx_f) will see the
parallel changes if we don't.
From the original report:
After `bup save`, `git fsck` would show messages like
"Packfile index for %s SHA1 mismatch"
This indicated a bad trailing checksum on the pack index file.
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Reported-by: Alan Jenkins <alan.christopher.jenkins@gmail.com>
Reviewed-by: Alan Jenkins <alan.christopher.jenkins@gmail.com>
Tested-by: Alan Jenkins <alan.christopher.jenkins@gmail.com>
idx_f.seek(0, os.SEEK_END)
count = _helpers.write_idx(idx_f, idx_map, idx, self.count)
assert(count == self.count)
+ # Sync, since it doesn't look like POSIX guarantees that a
+ # matching FILE* (i.e. idx_f) will see the parallel changes if
+ # we don't.
+ idx_map.flush()
idx_map.close()
idx_f.write(packbin)