[CalendarServer-changes] [3049] CalendarServer/trunk/twistedcaldav/directory/xmlfile.py

source_changes at macosforge.org source_changes at macosforge.org
Wed Sep 24 15:24:37 PDT 2008


Revision: 3049
          http://trac.macosforge.org/projects/calendarserver/changeset/3049
Author:   wsanchez at apple.com
Date:     2008-09-24 15:24:36 -0700 (Wed, 24 Sep 2008)
Log Message:
-----------
Don't restat the accounts file more than once per minute.

Modified Paths:
--------------
    CalendarServer/trunk/twistedcaldav/directory/xmlfile.py

Modified: CalendarServer/trunk/twistedcaldav/directory/xmlfile.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/xmlfile.py	2008-09-24 20:14:03 UTC (rev 3048)
+++ CalendarServer/trunk/twistedcaldav/directory/xmlfile.py	2008-09-24 22:24:36 UTC (rev 3049)
@@ -22,6 +22,8 @@
     "XMLDirectoryService",
 ]
 
+from time import time
+
 from twisted.cred.credentials import UsernamePassword
 from twisted.web2.auth.digest import DigestedCredentials
 from twisted.python.filepath import FilePath
@@ -48,6 +50,7 @@
 
         self.xmlFile = xmlFile
         self._fileInfo = None
+        self._lastCheck = 0
         self._accounts()
 
     def recordTypes(self):
@@ -88,7 +91,10 @@
             return
 
     def _accounts(self):
-        self.xmlFile.restat()
+        currentTime = time()
+        if currentTime - self._lastCheck > 60:
+            self.xmlFile.restat()
+            self._lastCheck = currentTime
         fileInfo = (self.xmlFile.getmtime(), self.xmlFile.getsize())
         if fileInfo != self._fileInfo:
             parser = XMLAccountsParser(self.xmlFile)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20080924/ca0388bb/attachment.html 


More information about the calendarserver-changes mailing list