[CalendarServer-changes] [4748] CalendarServer/trunk/twistedcaldav
source_changes at macosforge.org
source_changes at macosforge.org
Fri Nov 13 16:04:17 PST 2009
Revision: 4748
http://trac.macosforge.org/projects/calendarserver/changeset/4748
Author: glyph at apple.com
Date: 2009-11-13 16:04:17 -0800 (Fri, 13 Nov 2009)
Log Message:
-----------
Evolve test_calendarsUpgradeWithDSStore into the more general test_calendarsUpgradeWithUnknownFiles and test for unknown files in calendar homes as well.
Modified Paths:
--------------
CalendarServer/trunk/twistedcaldav/test/test_upgrade.py
CalendarServer/trunk/twistedcaldav/upgrade.py
Modified: CalendarServer/trunk/twistedcaldav/test/test_upgrade.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/test/test_upgrade.py 2009-11-13 19:38:26 UTC (rev 4747)
+++ CalendarServer/trunk/twistedcaldav/test/test_upgrade.py 2009-11-14 00:04:17 UTC (rev 4748)
@@ -14,6 +14,10 @@
# limitations under the License.
##
+
+from twisted.python.filepath import FilePath
+from twisted.web2.dav import davxml
+
from twistedcaldav.config import config
from twistedcaldav.directory.calendaruserproxy import CalendarUserProxyDatabase
from twistedcaldav.directory.xmlfile import XMLDirectoryService
@@ -22,7 +26,6 @@
from twistedcaldav.upgrade import UpgradeError, upgradeData, updateFreeBusySet
from twistedcaldav.test.util import TestCase
from calendarserver.tools.util import getDirectory
-from twisted.web2.dav import davxml
import hashlib
import os, zlib, cPickle
@@ -562,14 +565,36 @@
- def test_calendarsUpgradeWithDSStore(self):
+ def test_calendarsUpgradeWithUnknownFiles(self):
"""
- Verify that .DS_Store files don't hinder an upgrade
+ Unknown files, including .DS_Store files at any point in the hierarchy,
+ as well as non-directory in a user's calendar home, will be ignored and not
+ interrupt an upgrade.
"""
self.setUpXMLDirectory()
directory = getDirectory()
+ ignoredUIDContents = {
+ "64" : {
+ "23" : {
+ "6423F94A-6B76-4A3A-815B-D52CFD77935D" : {
+ "calendar" : {
+ },
+ "garbage.ics" : {
+ "@contents": "Oops, not actually an ICS file.",
+ },
+ "other-file.txt": {
+ "@contents": "Also not a calendar collection."
+ }
+ }
+ }
+ },
+ ".DS_Store" : {
+ "@contents" : "",
+ }
+ }
+
before = {
".DS_Store" :
{
@@ -581,13 +606,7 @@
{
"@contents" : "",
},
- "__uids__" :
- {
- ".DS_Store" :
- {
- "@contents" : "",
- },
- },
+ "__uids__" :ignoredUIDContents,
},
"principals" :
{
@@ -623,13 +642,7 @@
{
"@contents" : "",
},
- "__uids__" :
- {
- ".DS_Store" :
- {
- "@contents" : "",
- },
- },
+ "__uids__" : ignoredUIDContents,
},
CalendarUserProxyDatabase.dbFilename :
{
Modified: CalendarServer/trunk/twistedcaldav/upgrade.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/upgrade.py 2009-11-13 19:38:26 UTC (rev 4747)
+++ CalendarServer/trunk/twistedcaldav/upgrade.py 2009-11-14 00:04:17 UTC (rev 4748)
@@ -1,3 +1,4 @@
+# -*- test-case-name: twistedcaldav.test.test_upgrade -*-
##
# Copyright (c) 2008 Apple Inc. All rights reserved.
#
@@ -177,6 +178,10 @@
try:
for cal in os.listdir(homePath):
calPath = os.path.join(homePath, cal)
+ if not os.path.isdir(calPath):
+ # Skip non-directories; these might have been uploaded by a
+ # random DAV client, they can't be calendar collections.
+ continue
log.debug("Upgrading calendar: %s" % (calPath,))
if not upgradeCalendarCollection(calPath, directory):
errorOccurred = True
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20091113/9153d5e5/attachment-0001.html>
More information about the calendarserver-changes
mailing list