[CalendarServer-changes] [8984] CalendarServer/trunk/calendarserver/tools/shell/vfs.py

source_changes at macosforge.org source_changes at macosforge.org
Wed Apr 4 16:52:40 PDT 2012


Revision: 8984
          http://trac.macosforge.org/projects/calendarserver/changeset/8984
Author:   wsanchez at apple.com
Date:     2012-04-04 16:52:40 -0700 (Wed, 04 Apr 2012)
Log Message:
-----------
Fix hang in ls /users/foo by avoiding writes in the DB transaction.

Modified Paths:
--------------
    CalendarServer/trunk/calendarserver/tools/shell/vfs.py

Modified: CalendarServer/trunk/calendarserver/tools/shell/vfs.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/shell/vfs.py	2012-04-04 22:57:26 UTC (rev 8983)
+++ CalendarServer/trunk/calendarserver/tools/shell/vfs.py	2012-04-04 23:52:40 UTC (rev 8984)
@@ -206,6 +206,7 @@
         result = set()
 
         # FIXME ...?
+        yield 1
 
         returnValue(result)
 
@@ -257,7 +258,7 @@
     @inlineCallbacks
     def _initChildren(self):
         if not hasattr(self, "_didInitChildren"):
-            txn  = self.service.store.newTransaction()
+            txn = self.service.store.newTransaction()
 
             if (
                 self.record is not None and
@@ -268,7 +269,21 @@
             else:
                 create = False
 
-            home = (yield txn.calendarHomeWithUID(self.uid, create=create))
+            # Try assuming it exists
+            home = (yield txn.calendarHomeWithUID(self.uid, create=False))
+
+            if home is None and create:
+                # Doesn't exist, so create it in a different
+                # transaction, to avoid having to commit the live
+                # transaction.
+                txnTemp = self.service.store.newTransaction()
+                home = (yield txnTemp.calendarHomeWithUID(self.uid, create=True))
+                (yield txnTemp.commit())
+
+                # Fetch the home again. This time we expect it to be there.
+                home = (yield txn.calendarHomeWithUID(self.uid, create=False))
+                assert home
+
             if home:
                 self._children["calendars"] = CalendarHomeFolder(
                     self.service,
@@ -285,7 +300,19 @@
             else:
                 create = False
 
+            # Again, assume it exists
             home = (yield txn.addressbookHomeWithUID(self.uid))
+
+            if not home and create:
+                # Repeat the above dance.
+                txnTemp = self.service.store.newTransaction()
+                home = (yield txnTemp.addressbookHomeWithUID(self.uid, create=True))
+                (yield txnTemp.commit())
+
+                # Fetch the home again. This time we expect it to be there.
+                home = (yield txn.addressbookHomeWithUID(self.uid, create=False))
+                assert home
+
             if home:
                 self._children["addressbooks"] = AddressBookHomeFolder(
                     self.service,
@@ -593,10 +620,16 @@
 
         returnValue("Calendar object:\n%s" % tableString(rows))
 
+
 class AddressBookHomeFolder(Folder):
     """
     Address book home folder.
     """
+    def __init__(self, service, path, home):
+        Folder.__init__(self, service, path)
+
+        self.home = home
+
     # FIXME
 
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20120404/4a88bee9/attachment-0001.html>


More information about the calendarserver-changes mailing list