sync_dir: silence fsync() failing with EINVAL

This commit is contained in:
Marian Beermann 2016-07-08 18:05:21 +02:00
parent fe627246e4
commit 567617ebbe
No known key found for this signature in database
GPG Key ID: 9B8450B91D1362C1
1 changed files with 6 additions and 0 deletions

View File

@ -1,3 +1,4 @@
import errno
import os import os
""" """
@ -52,6 +53,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)