cachefile = open(CACHE_FILENAME, 'rb')
self.version, self.data = pickle.load(cachefile)
if(self.version != CACHE_VERSION):
- logging.warning("Cache file has version %s and the script version is %s.",
+ logging.warning("Cache file has version %s and the script version is %s. Deleting cache.",
self.version, CACHE_VERSION)
raise IOError
- logging.info("Cache version %s", self.version)
+ logging.info("Cache file %s loaded", CACHE_FILENAME)
logging.debug("%s users found.", len(self.data))
except IOError:
self.version = CACHE_VERSION
file_descriptor, tmpname = tempfile.mkstemp(dir=location)
try:
cachefile = os.fdopen(file_descriptor, 'wb')
-
+
# prepare data based on a save flag
saved_data = {}
for user in self.data:
cachefile.close()
os.unlink(tmpname)
return
-
+
# serialize in file
pickle.dump((self.version, self.data), cachefile)
logging.debug("%s users stored.", len(self.data))
os.rename(tmpname, CACHE_FILENAME)
except:
- os.unlink(tmpname)
+ os.unlink(tmpname)
+
+ logging.info("Wrote cache file %s", CACHE_FILENAME)
def retrieve_cached_mailbox(self, name, uidvalidity, user):
"""Retrieve a cached mailbox or create it."""