[CalendarServer-changes] [4595] CalendarServer/branches/users/sagen/deployment-inherit-fds-4571/ twistedcaldav/directory/appleopendirectory.py
source_changes at macosforge.org
source_changes at macosforge.org
Mon Oct 19 09:56:15 PDT 2009
Revision: 4595
http://trac.macosforge.org/projects/calendarserver/changeset/4595
Author: sagen at apple.com
Date: 2009-10-19 09:56:14 -0700 (Mon, 19 Oct 2009)
Log Message:
-----------
Handle a missing cache file
Modified Paths:
--------------
CalendarServer/branches/users/sagen/deployment-inherit-fds-4571/twistedcaldav/directory/appleopendirectory.py
Modified: CalendarServer/branches/users/sagen/deployment-inherit-fds-4571/twistedcaldav/directory/appleopendirectory.py
===================================================================
--- CalendarServer/branches/users/sagen/deployment-inherit-fds-4571/twistedcaldav/directory/appleopendirectory.py 2009-10-19 14:33:44 UTC (rev 4594)
+++ CalendarServer/branches/users/sagen/deployment-inherit-fds-4571/twistedcaldav/directory/appleopendirectory.py 2009-10-19 16:56:14 UTC (rev 4595)
@@ -133,7 +133,12 @@
for recordType in self.recordTypes():
self.log_debug("Master fetching %s from directory" % (recordType,))
cacheFile = cacheDir.child(recordType)
- results = self._queryDirectory(recordType)
+ try:
+ results = self._queryDirectory(recordType)
+ except Exception, e:
+ self.log_error("Master query for %s failed: %s" % (recordType, e))
+ continue
+
results.sort()
pickled = pickle.dumps(results)
needsWrite = True
@@ -150,10 +155,10 @@
def _refreshInThread(self):
return deferToThread(_refresh, self)
+ _refresh(self)
+
if loop:
LoopingCall(_refreshInThread, self).start(self.cacheTimeout * 60)
- else:
- _refresh(self)
@@ -635,24 +640,26 @@
cacheFile = cacheDir.child(recordType)
if not cacheFile.exists():
self.log_error("Directory cache file for %s does not exist: %s" % (recordType, cacheFile.path))
- return
- lastModified = cacheFile.getModificationTime()
- try:
- storage = self._records[recordType]
- if not forceUpdate and (lastModified <= storage["last modified"]):
- self.log_debug("Directory cache file for %s unchanged" % (recordType,))
- storage["status"] = "new" # mark this as not stale
- self._delayedCalls.add(callLater(cacheTimeout, rot))
- return
- except KeyError:
- # Haven't read the file before
- pass
+ results = []
+ lastModified = 0
+ else:
+ lastModified = cacheFile.getModificationTime()
+ try:
+ storage = self._records[recordType]
+ if not forceUpdate and (lastModified <= storage["last modified"]):
+ self.log_debug("Directory cache file for %s unchanged" % (recordType,))
+ storage["status"] = "new" # mark this as not stale
+ self._delayedCalls.add(callLater(cacheTimeout, rot))
+ return
+ except KeyError:
+ # Haven't read the file before
+ pass
- self.log_info("Reloading %s record cache" % (recordType,))
+ self.log_info("Reloading %s record cache" % (recordType,))
- pickled = cacheFile.getContent()
- results = pickle.loads(pickled)
- # results = self._queryDirectory(recordType)
+ pickled = cacheFile.getContent()
+ results = pickle.loads(pickled)
+ # results = self._queryDirectory(recordType)
records = {}
guids = {}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20091019/598a64fa/attachment.html>
More information about the calendarserver-changes
mailing list