[CalendarServer-changes] [2436] CalendarServer/trunk/twistedcaldav
source_changes at macosforge.org
source_changes at macosforge.org
Tue May 20 13:31:27 PDT 2008
Revision: 2436
http://trac.macosforge.org/projects/calendarserver/changeset/2436
Author: wsanchez at apple.com
Date: 2008-05-20 13:31:27 -0700 (Tue, 20 May 2008)
Log Message:
-----------
Put __uids__ subdirs into nested subdirs in order to avoid too many children in one directory.
Modified Paths:
--------------
CalendarServer/trunk/twistedcaldav/directory/principal.py
CalendarServer/trunk/twistedcaldav/static.py
Modified: CalendarServer/trunk/twistedcaldav/directory/principal.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/principal.py 2008-05-20 17:45:00 UTC (rev 2435)
+++ CalendarServer/trunk/twistedcaldav/directory/principal.py 2008-05-20 20:31:27 UTC (rev 2436)
@@ -333,10 +333,13 @@
log.err("No principal found for UID: %s" % (name,))
return None
+ assert len(name) > 4
+ childPath = self.fp.child(name[0:2]).child(name[2:4]).child(name)
+
if record.enabledForCalendaring:
- primaryPrincipal = DirectoryCalendarPrincipalResource(self.fp.child(name).path, self, record)
+ primaryPrincipal = DirectoryCalendarPrincipalResource(childPath.path, self, record)
else:
- primaryPrincipal = DirectoryPrincipalResource(self.fp.child(name).path, self, record)
+ primaryPrincipal = DirectoryPrincipalResource(childPath.path, self, record)
if subType is None:
return primaryPrincipal
Modified: CalendarServer/trunk/twistedcaldav/static.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/static.py 2008-05-20 17:45:00 UTC (rev 2435)
+++ CalendarServer/trunk/twistedcaldav/static.py 2008-05-20 20:31:27 UTC (rev 2436)
@@ -487,26 +487,36 @@
log.msg("Directory record %r is not enabled for calendaring" % (record,))
return None
- childPath = self.fp.child(name)
+ assert len(name) > 4
+
+ childPath = self.fp.child(name[0:2]).child(name[2:4]).child(name)
child = self.homeResourceClass(childPath.path, self, record)
+
if not child.exists():
self.provision()
- oldPath = self.parent.getChild(record.recordType).fp.child(record.shortName)
- if oldPath.exists():
- #
- # The child exists at the old (pre-1.2) location (ie. in the types
- # hierarchy instead of the GUID hierarchy). Move to new location.
- #
- log.msg("Moving calendar home from old location %r to new location %r." % (oldPath, childPath))
- try:
- oldPath.moveTo(childPath)
- except (OSError, IOError), e:
- log.err("Error moving calendar home %r: %s" % (oldPath, e))
- raise HTTPError(StatusResponse(
- responsecode.INTERNAL_SERVER_ERROR,
- "Unable to move calendar home."
- ))
+ if not childPath.parent().isdir():
+ childPath.parent().makedirs()
+
+ for oldPath in (
+ # Pre 2.0: All in one directory
+ self.fp.child(name),
+ # Pre 1.2: In types hierarchy instead of the GUID hierarchy
+ self.parent.getChild(record.recordType).fp.child(record.shortName),
+ ):
+ if oldPath.exists():
+ # The child exists at an old location. Move to new location.
+ log.msg("Moving calendar home from old location %r to new location %r." % (oldPath, childPath))
+ try:
+ oldPath.moveTo(childPath)
+ except (OSError, IOError), e:
+ log.err("Error moving calendar home %r: %s" % (oldPath, e))
+ raise HTTPError(StatusResponse(
+ responsecode.INTERNAL_SERVER_ERROR,
+ "Unable to move calendar home."
+ ))
+ child.fp.restat(False)
+ break
else:
#
# NOTE: provisionDefaultCalendars() returns a deferred, which we are ignoring.
@@ -515,6 +525,19 @@
# on that to finish.
#
child.provisionDefaultCalendars()
+
+ #
+ # Try to work around the above a little by telling the client that something
+ # when wrong temporarily if the child isn't provisioned right away.
+ #
+ if not child.exists():
+ raise HTTPError(StatusResponse(
+ responsecode.SERVICE_UNAVAILABLE,
+ "Provisioning calendar home."
+ ))
+
+ assert child.exists()
+
return child
def createSimilarFile(self, path):
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20080520/6eacb252/attachment.htm
More information about the calendarserver-changes
mailing list