From ba5fe590c952180dee93fc27bf66f15b7a7c7f42 Mon Sep 17 00:00:00 2001 From: Unrud Date: Thu, 3 Aug 2017 19:46:58 +0200 Subject: [PATCH] Improve error message when fsync'ing files fails --- radicale/storage.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/radicale/storage.py b/radicale/storage.py index 3708558..d00c043 100644 --- a/radicale/storage.py +++ b/radicale/storage.py @@ -736,7 +736,11 @@ class Collection(BaseCollection): newline=newline, encoding=None if "b" in mode else self._encoding) try: yield tmp - self._fsync(tmp.fileno()) + try: + self._fsync(tmp.fileno()) + except OSError as e: + raise RuntimeError("Fsync'ing file %r failed: %s" % + (path, e)) from e tmp.close() os.replace(tmp.name, path) except: @@ -952,7 +956,11 @@ class Collection(BaseCollection): fs[-1].write(text) # sync everything at once because it's slightly faster. for f in fs: - self._fsync(f.fileno()) + try: + self._fsync(f.fileno()) + except OSError as e: + raise RuntimeError("Fsync'ing file %r failed: %s" % + (f.name, e)) from e self._sync_directory(self._filesystem_path) @classmethod