# Local status cache virtual folder
-# Copyright (C) 2002 - 2003 John Goerzen
+# Copyright (C) 2002 - 2008 John Goerzen
# <jgoerzen@complete.org>
#
# This program is free software; you can redistribute it and/or modify
file = open(self.filename, "rt")
self.messagelist = {}
line = file.readline().strip()
+ if not line and not line.read():
+ # The status file is empty - should not have happened,
+ # but somehow did.
+ file.close()
+ return
assert(line == magicline)
for line in file.xreadlines():
line = line.strip()
flags.sort()
flags = ''.join(flags)
file.write("%s:%s\n" % (msg['uid'], flags))
+ file.flush()
+ os.fsync(file.fileno())
file.close()
os.rename(self.filename + ".tmp", self.filename)
+
+ try:
+ fd = os.open(os.path.dirname(self.filename), os.O_RDONLY)
+ os.fsync(fd)
+ os.close(fd)
+ except:
+ pass
+
finally:
self.savelock.release()