Fixes the error:
Traceback (most recent call last):
File "/usr/local/Cellar/bup/0.28.1/lib/bup/cmd/bup-server", line 209, in <module>
cmd(conn, rest)
File "/usr/local/Cellar/bup/0.28.1/lib/bup/cmd/bup-server", line 91, in receive_objects_v2
fullpath = w.close(run_midx=not dumb_server_mode)
File "/usr/local/Cellar/bup/0.28.1/lib/bup/bup/git.py", line 790, in close
return self._end(run_midx=run_midx)
File "/usr/local/Cellar/bup/0.28.1/lib/bup/bup/git.py", line 764, in _end
fdatasync(f.fileno())
File "/usr/local/Cellar/bup/0.28.1/lib/bup/bup/helpers.py", line 47, in <lambda>
fdatasync = lambda fd : fcntl.fcntl(fd, fcntl.F_FULLFSYNC)
IOError: [Errno 45] Operation not supported
Traceback (most recent call last):
File "/usr/local/Cellar/bup/0.28.1/lib/bup/cmd/bup-save", line 460, in <module>
w.close() # must close before we can update the ref
File "/usr/local/Cellar/bup/0.28.1/lib/bup/bup/client.py", line 317, in close
id = self._end()
File "/usr/local/Cellar/bup/0.28.1/lib/bup/bup/client.py", line 314, in _end
return self.suggest_packs() # Returns last idx received
File "/usr/local/Cellar/bup/0.28.1/lib/bup/bup/client.py", line 229, in _suggest_packs
self.check_ok()
File "/usr/local/Cellar/bup/0.28.1/lib/bup/bup/client.py", line 134, in check_ok
% rv)
Signed-off-by: Jonathan Wright <quaggy@gmail.com>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
buglvl = atoi(os.environ.get('BUP_DEBUG', 0))
+try:
+ _fdatasync = os.fdatasync
+except AttributeError:
+ _fdatasync = os.fsync
+
if sys.platform.startswith('darwin'):
- # Apparently fsync on OS X doesn't guarantee to sync all the way down
+ # Apparently os.fsync on OS X doesn't guarantee to sync all the way down
import fcntl
- fdatasync = lambda fd : fcntl.fcntl(fd, fcntl.F_FULLFSYNC)
-else: # If the platform doesn't have fdatasync, fall back to fsync
- try:
- fdatasync = os.fdatasync
- except AttributeError:
- fdatasync = os.fsync
+ def fdatasync(fd):
+ try:
+ return fcntl.fcntl(fd, fcntl.F_FULLFSYNC)
+ except IOError as e:
+ # Fallback for file systems (SMB) that do not support F_FULLFSYNC
+ if e.errno == errno.ENOTSUP:
+ return _fdatasync(fd)
+ else:
+ raise
+else:
+ fdatasync = _fdatasync
# Write (blockingly) to sockets that may or may not be in blocking mode.