| 103 | |
| 104 | |
| 105 | def sync_dir(path): |
| 106 | if is_win32: |
| 107 | # Opening directories is not supported on Windows. |
| 108 | # TODO: Do we need to handle this in some other way? |
| 109 | return |
| 110 | fd = os.open(str(path), os.O_RDONLY) |
| 111 | try: |
| 112 | os.fsync(fd) |
| 113 | except OSError as os_error: |
| 114 | # Some network filesystems don't support this and fail with EINVAL. |
| 115 | # Other error codes (e.g. EIO) shouldn't be silenced. |
| 116 | if os_error.errno != errno.EINVAL: |
| 117 | raise |
| 118 | finally: |
| 119 | os.close(fd) |
| 120 | |
| 121 | |
| 122 | def safe_fadvise(fd, offset, len, advice): |