Improve error message when fsync'ing files fails
This commit is contained in:
parent
ae54e8556c
commit
ba5fe590c9
@ -736,7 +736,11 @@ class Collection(BaseCollection):
|
|||||||
newline=newline, encoding=None if "b" in mode else self._encoding)
|
newline=newline, encoding=None if "b" in mode else self._encoding)
|
||||||
try:
|
try:
|
||||||
yield tmp
|
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()
|
tmp.close()
|
||||||
os.replace(tmp.name, path)
|
os.replace(tmp.name, path)
|
||||||
except:
|
except:
|
||||||
@ -952,7 +956,11 @@ class Collection(BaseCollection):
|
|||||||
fs[-1].write(text)
|
fs[-1].write(text)
|
||||||
# sync everything at once because it's slightly faster.
|
# sync everything at once because it's slightly faster.
|
||||||
for f in fs:
|
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)
|
self._sync_directory(self._filesystem_path)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
Loading…
x
Reference in New Issue
Block a user