[PATCH 3/4] LocalStatus: Don't ignore Exceptions on os.fsync

Sebastian Spaeth Sebastian at SSpaeth.de
Mon Jan 10 10:00:40 GMT 2011

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

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 at SSpaeth.de>
 offlineimap/folder/LocalStatus.py |   12 +++---------
 1 files 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)

More information about the OfflineIMAP-project mailing list