From 760698253bacb7c6d8f0267fe42ac63c0f83d475 Mon Sep 17 00:00:00 2001 From: Sebastian Spaeth Date: Wed, 12 Jan 2011 11:15:10 +0100 Subject: [PATCH] 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 Signed-off-by: Nicolas Sebrecht --- offlineimap/folder/LocalStatus.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/offlineimap/folder/LocalStatus.py b/offlineimap/folder/LocalStatus.py index 3195886..50a0f55 100644 --- a/offlineimap/folder/LocalStatus.py +++ b/offlineimap/folder/LocalStatus.py @@ -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()