LocalStatus: Don't ignore Exceptions on os.fsync

Earlier we would ignore *ALL* Exceptions that could occur during the
fsyncing of our LocalStatus database. Ignoring all Exceptions is not the
right thing here though. A recent commit improved the situation by
raising at least KeyboardInterrupt Exceptions, but that is still not
optimal.

os.fsync() is available on Unix, and Windows starting in python
2.2.3. so it should always work. If it doesn't, something is wrong.

It has been suggested to only catch EnvironmentError (ie SystemError and
OSError) here, but even those should be thrown. Something *is* wrong if
this fails and we should not ignore it.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
Sebastian Spaeth 2011-01-12 11:15:10 +01:00 committed by Nicolas Sebrecht
parent 1a1e68d8be
commit 760698253b

View File

@ -104,15 +104,9 @@ class LocalStatusFolder(BaseFolder):
os.rename(self.filename + ".tmp", self.filename)
if self.dofsync:
try:
fd = os.open(os.path.dirname(self.filename), os.O_RDONLY)
os.fsync(fd)
os.close(fd)
except (KeyboardInterrupt):
raise
except:
#TODO, we should catch a specific Exception here, not ALL. But which?
pass
fd = os.open(os.path.dirname(self.filename), os.O_RDONLY)
os.fsync(fd)
os.close(fd)
finally:
self.savelock.release()