[CalendarServer-changes] [3752] CalendarServer/branches/users/sagen/migration-3735/twistedcaldav
source_changes at macosforge.org
source_changes at macosforge.org
Thu Feb 26 11:33:20 PST 2009
Revision: 3752
http://trac.macosforge.org/projects/calendarserver/changeset/3752
Author: sagen at apple.com
Date: 2009-02-26 11:33:20 -0800 (Thu, 26 Feb 2009)
Log Message:
-----------
When a resource is not fixable, allow the procedure to continue (logging each error along the way), but abort the upgrade at the end. This allows an admin to check the error.log for all failures, fix them, and restart the server.
Modified Paths:
--------------
CalendarServer/branches/users/sagen/migration-3735/twistedcaldav/test/test_upgrade.py
CalendarServer/branches/users/sagen/migration-3735/twistedcaldav/upgrade.py
Modified: CalendarServer/branches/users/sagen/migration-3735/twistedcaldav/test/test_upgrade.py
===================================================================
--- CalendarServer/branches/users/sagen/migration-3735/twistedcaldav/test/test_upgrade.py 2009-02-26 19:04:38 UTC (rev 3751)
+++ CalendarServer/branches/users/sagen/migration-3735/twistedcaldav/test/test_upgrade.py 2009-02-26 19:33:20 UTC (rev 3752)
@@ -728,6 +728,94 @@
+
+ def test_calendarsUpgradeWithError(self):
+ """
+ Verify that a problem with one resource doesn't stop the process, but
+ also doesn't write the new version file
+ """
+
+ self.setUpXMLDirectory()
+ directory = getDirectory()
+
+ before = {
+ "calendars" :
+ {
+ "__uids__" :
+ {
+ "64" :
+ {
+ "23" :
+ {
+ "6423F94A-6B76-4A3A-815B-D52CFD77935E" :
+ {
+ "calendar" :
+ {
+ "1E238CA1-3C95-4468-B8CD-C8A399F78C72.ics" :
+ {
+ "@contents" : event01_before,
+ },
+ "1E238CA1-3C95-4468-B8CD-C8A399F78C73.ics" :
+ {
+ "@contents" : event02_broken,
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ CalendarUserProxyDatabase.dbFilename :
+ {
+ "@contents" : "",
+ }
+ }
+
+
+ after = {
+ "calendars" :
+ {
+ "__uids__" :
+ {
+ "64" :
+ {
+ "23" :
+ {
+ "6423F94A-6B76-4A3A-815B-D52CFD77935E" :
+ {
+ "calendar" :
+ {
+ "1E238CA1-3C95-4468-B8CD-C8A399F78C72.ics" :
+ {
+ "@contents" : event01_after,
+ },
+ "1E238CA1-3C95-4468-B8CD-C8A399F78C73.ics" :
+ {
+ "@contents" : event02_broken,
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ CalendarUserProxyDatabase.dbFilename :
+ {
+ "@contents" : "",
+ }
+ }
+
+
+ root = self.createHierarchy(before)
+
+ config.DocumentRoot = root
+ config.DataRoot = root
+
+ self.assertRaises(UpgradeError, upgradeData, config)
+ self.assertTrue(self.verifyHierarchy(root, after))
+
+
+
event01_before = """BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Apple Inc.//iCal 3.0//EN
@@ -811,6 +899,7 @@
END:VCALENDAR
""".replace("\n", "\r\n")
+event02_broken = "Invalid!"
def isValidCTag(value):
"""
Modified: CalendarServer/branches/users/sagen/migration-3735/twistedcaldav/upgrade.py
===================================================================
--- CalendarServer/branches/users/sagen/migration-3735/twistedcaldav/upgrade.py 2009-02-26 19:04:38 UTC (rev 3751)
+++ CalendarServer/branches/users/sagen/migration-3735/twistedcaldav/upgrade.py 2009-02-26 19:33:20 UTC (rev 3752)
@@ -34,14 +34,18 @@
+
#
# upgrade_to_1
#
# Upconverts data from any calendar server version prior to data format 1
#
+errorOccurred = False
def upgrade_to_1(config):
+ global errorOccurred
+ errorOccurred = False
def fixBadQuotes(data):
if (
@@ -88,6 +92,8 @@
def upgradeCalendarCollection(calPath, directory):
+ global errorOccurred
+
collectionUpdated = False
for resource in os.listdir(calPath):
@@ -114,7 +120,8 @@
except Exception, e:
log.error("Error while fixing bad quotes in %s: %s" %
(resPath, e))
- raise
+ errorOccurred = True
+ continue
try:
data, fixed = normalizeCUAddrs(data, directory)
@@ -124,7 +131,8 @@
except Exception, e:
log.error("Error while normalizing %s: %s" %
(resPath, e))
- raise
+ errorOccurred = True
+ continue
if needsRewrite:
with open(resPath, "w") as res:
@@ -303,6 +311,8 @@
homePath = os.path.join(secondPath, home)
upgradeCalendarHome(homePath, directory)
+ if errorOccurred:
+ raise UpgradeError("Data upgrade failed, see error.log for details")
# The on-disk version number (which defaults to zero if .calendarserver_version
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20090226/ed2204fd/attachment-0001.html>
More information about the calendarserver-changes
mailing list