[CalendarServer-changes] [8594] CalendarServer/trunk/txdav

source_changes at macosforge.org source_changes at macosforge.org
Thu Jan 26 16:24:59 PST 2012


Revision: 8594
          http://trac.macosforge.org/projects/calendarserver/changeset/8594
Author:   glyph at apple.com
Date:     2012-01-26 16:24:58 -0800 (Thu, 26 Jan 2012)
Log Message:
-----------
fix for file-backed calendarObjects/addressbookObjects incorrectly picking up directories within collections as objects, when they should really just be ignored.

Modified Paths:
--------------
    CalendarServer/trunk/txdav/caldav/datastore/test/test_file.py
    CalendarServer/trunk/txdav/caldav/datastore/test/test_scheduling.py
    CalendarServer/trunk/txdav/carddav/datastore/test/test_file.py
    CalendarServer/trunk/txdav/common/datastore/file.py

Modified: CalendarServer/trunk/txdav/caldav/datastore/test/test_file.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/test/test_file.py	2012-01-26 19:25:51 UTC (rev 8593)
+++ CalendarServer/trunk/txdav/caldav/datastore/test/test_file.py	2012-01-27 00:24:58 UTC (rev 8594)
@@ -477,12 +477,24 @@
     @inlineCallbacks
     def test_calendarObjectsWithDotFile(self):
         """
-        Adding a dotfile to the calendar home should not increase
+        Adding a dotfile to the calendar home should not increase the number of
+        calendar objects discovered.
         """
         (yield self.homeUnderTest())._path.child(".foo").createDirectory()
         yield self.test_calendarObjects()
 
 
+    @inlineCallbacks
+    def test_calendarObjectsWithDirectory(self):
+        """
+        If a directory appears (even a non-hidden one) within a calendar, it
+        should not show up in the directory listing.
+        """
+        ((yield self.calendarUnderTest())._path.child("not-a-calendar-object")
+         .createDirectory())
+        yield self.test_calendarObjects()
+
+
     def test_simpleHomeSyncToken(self):
         """
         File store doesn't have a functioning C{resourceNamesSinceToken} for

Modified: CalendarServer/trunk/txdav/caldav/datastore/test/test_scheduling.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/test/test_scheduling.py	2012-01-26 19:25:51 UTC (rev 8593)
+++ CalendarServer/trunk/txdav/caldav/datastore/test/test_scheduling.py	2012-01-27 00:24:58 UTC (rev 8594)
@@ -63,5 +63,6 @@
     test_calendarObjectsWithDotFile = skipit
     test_countComponentTypes = skipit
     test_init = skipit
+    test_calendarObjectsWithDirectory = skipit
 
 del FileStorageTests

Modified: CalendarServer/trunk/txdav/carddav/datastore/test/test_file.py
===================================================================
--- CalendarServer/trunk/txdav/carddav/datastore/test/test_file.py	2012-01-26 19:25:51 UTC (rev 8593)
+++ CalendarServer/trunk/txdav/carddav/datastore/test/test_file.py	2012-01-27 00:24:58 UTC (rev 8594)
@@ -479,3 +479,15 @@
         self.homeUnderTest()._path.child(".foo").createDirectory()
         yield self.test_addressbookObjects()
 
+
+    @inlineCallbacks
+    def test_addressbookObjectsWithDirectory(self):
+        """
+        If a directory appears (even a non-hidden one) within an addressbook, it
+        should not show up in the directory listing.
+        """
+        ((yield self.addressbookUnderTest())._path.child("not-a-vcard")
+         .createDirectory())
+        yield self.test_addressbookObjects()
+
+

Modified: CalendarServer/trunk/txdav/common/datastore/file.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/file.py	2012-01-26 19:25:51 UTC (rev 8593)
+++ CalendarServer/trunk/txdav/common/datastore/file.py	2012-01-27 00:24:58 UTC (rev 8594)
@@ -759,16 +759,8 @@
         """
         Return a list of object resource objects.
         """
-        return sorted((
-            self.objectResourceWithName(name)
-            for name in (
-                set(self._newObjectResources.iterkeys()) |
-                set(name for name in self._path.listdir()
-                    if not name.startswith(".")) -
-                set(self._removedObjectResources)
-            )),
-            key=lambda calObj: calObj.name()
-        )
+        return [self.objectResourceWithName(name)
+                for name in self.listObjectResources()]
 
 
     def listObjectResources(self):
@@ -779,8 +771,9 @@
             name
             for name in (
                 set(self._newObjectResources.iterkeys()) |
-                set(name for name in self._path.listdir()
-                    if not name.startswith(".")) -
+                set(p.basename() for p in self._path.children()
+                    if not p.basename().startswith(".") and
+                    p.isfile()) -
                 set(self._removedObjectResources)
             ))
         )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20120126/b1cc7726/attachment-0001.html>


More information about the calendarserver-changes mailing list