Have helpers.fdatasync() fall back to os.fsync() whenever
os.fdatasync() isn't available.
Thanks to Yann Autissier <yann.autissier@gmail.com> for reporting the
problem that prompted this work.
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
assert(f.tell() == 12)
f.truncate(12 + 4*entries + 20*total + 4*total)
+ f.flush()
+ fdatasync(f.fileno())
fmap = mmap_readwrite(f, close=False)
count = merge_into(fmap, bits, total, inp)
- del fmap
+ del fmap # Assume this calls msync() now.
f.seek(0, os.SEEK_END)
f.write('\0'.join(allfilenames))
buglvl = atoi(os.environ.get('BUP_DEBUG', 0))
+# If the platform doesn't have fdatasync (OS X), fall back to fsync.
+try:
+ fdatasync = os.fdatasync
+except AttributeError:
+ fdatasync = os.fsync
+
+
# Write (blockingly) to sockets that may or may not be in blocking mode.
# We need this because our stderr is sometimes eaten by subprocesses
# (probably ssh) that sometimes make it nonblocking, if only temporarily,