From: Rob Browning Date: Sat, 8 Jun 2013 15:25:33 +0000 (-0500) Subject: git.py: flush idx_map before close so FILE* operations will see changes. X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=ab2cef40af6a4c1adeb0f3ffb40e8ffa7530d5c6;p=packages%2Fb%2Fbup.git git.py: flush idx_map before close so FILE* operations will see changes. 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 Reported-by: Alan Jenkins Reviewed-by: Alan Jenkins Tested-by: Alan Jenkins --- diff --git a/lib/bup/git.py b/lib/bup/git.py index 403b969..00975a7 100644 --- a/lib/bup/git.py +++ b/lib/bup/git.py @@ -664,6 +664,10 @@ class PackWriter: 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)