浏览代码

sync_dir: silence fsync() failing with EINVAL

Some network filesystems don't support this.
Marian Beermann 9 年之前
父节点
当前提交
0005023a73
共有 1 个文件被更改,包括 6 次插入0 次删除
  1. 6 0
      borg/platform.py

+ 6 - 0
borg/platform.py

@@ -1,3 +1,4 @@
+import errno
 import os
 import os
 import sys
 import sys
 
 
@@ -7,6 +8,11 @@ def sync_dir(path):
     fd = os.open(path, os.O_RDONLY)
     fd = os.open(path, os.O_RDONLY)
     try:
     try:
         os.fsync(fd)
         os.fsync(fd)
+    except OSError as os_error:
+        # Some network filesystems don't support this and fail with EINVAL.
+        # Other error codes (e.g. EIO) shouldn't be silenced.
+        if os_error.errno != errno.EINVAL:
+            raise
     finally:
     finally:
         os.close(fd)
         os.close(fd)