Skip to content

Commit 0550497

Browse files
committed
One more CRAI improvement
1 parent 71ab715 commit 0550497

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

plugwise_usb/helpers/cache.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,14 @@ async def write_cache(self, data: dict[str, str], rewrite: bool = False) -> None
159159
temp_path = None # Successfully renamed
160160
if os_name != "nt":
161161
# Ensure directory entry is persisted on POSIX
162-
await loop.run_in_executor(
163-
None, _fsync_parent_dir, cache_file_path.parent
164-
)
162+
try:
163+
await loop.run_in_executor(
164+
None, _fsync_parent_dir, cache_file_path.parent
165+
)
166+
except (OSError, PermissionError):
167+
# Directory fsync may fail on some filesystems
168+
# The atomic rename is still complete
169+
pass
165170

166171
if not self._cache_file_exists:
167172
self._cache_file_exists = True

0 commit comments

Comments
 (0)