[CalendarServer-changes] [6357] CalendarServer/trunk/txdav
source_changes at macosforge.org
source_changes at macosforge.org
Thu Sep 23 14:00:42 PDT 2010
Revision: 6357
http://trac.macosforge.org/projects/calendarserver/changeset/6357
Author: cdaboo at apple.com
Date: 2010-09-23 14:00:41 -0700 (Thu, 23 Sep 2010)
Log Message:
-----------
Fix various migration issues.
Modified Paths:
--------------
CalendarServer/trunk/txdav/caldav/datastore/file.py
CalendarServer/trunk/txdav/caldav/datastore/sql.py
CalendarServer/trunk/txdav/common/datastore/file.py
CalendarServer/trunk/txdav/common/datastore/sql.py
CalendarServer/trunk/txdav/common/datastore/sql_schema_v1.sql
CalendarServer/trunk/txdav/common/datastore/util.py
Modified: CalendarServer/trunk/txdav/caldav/datastore/file.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/file.py 2010-09-23 20:12:19 UTC (rev 6356)
+++ CalendarServer/trunk/txdav/caldav/datastore/file.py 2010-09-23 21:00:41 UTC (rev 6357)
@@ -71,6 +71,8 @@
CalendarStoreTransaction = CommonStoreTransaction
+IGNORE_NAMES = ('dropbox', 'notification', 'freebusy')
+
class CalendarHome(CommonHome):
implements(ICalendarHome)
@@ -81,7 +83,7 @@
def calendarWithName(self, name):
- if name in ('dropbox', 'notifications', 'freebusy'):
+ if name in IGNORE_NAMES:
# "dropbox" is a file storage area, not a calendar.
return None
else:
@@ -95,17 +97,15 @@
"""
Return a generator of the child resource objects.
"""
- for child in self.children():
- if child.name() in ('dropbox', 'notification'):
- continue
- yield child
+ for child in self.listCalendars():
+ yield self.calendarWithName(child)
def listCalendars(self):
"""
Return a generator of the child resource names.
"""
for name in self.listChildren():
- if name in ('dropbox', 'notification'):
+ if name in IGNORE_NAMES:
continue
yield name
Modified: CalendarServer/trunk/txdav/caldav/datastore/sql.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/sql.py 2010-09-23 20:12:19 UTC (rev 6356)
+++ CalendarServer/trunk/txdav/caldav/datastore/sql.py 2010-09-23 21:00:41 UTC (rev 6357)
@@ -264,8 +264,13 @@
try:
instances = component.expandTimeRanges(expand, ignoreInvalidInstances=reCreate)
except InvalidOverriddenInstanceError, e:
- self.log_err("Invalid instance %s when indexing %s in %s" % (e.rid, self._name, self.resource,))
- raise
+ self.log_error("Invalid instance %s when indexing %s in %s" % (e.rid, self._name, self._calendar,))
+
+ if self._txn._migrating:
+ # TODO: fix the data here by re-writing component then re-index
+ instances = component.expandTimeRanges(expand, ignoreInvalidInstances=True)
+ else:
+ raise
componentText = str(component)
self._objectText = componentText
Modified: CalendarServer/trunk/txdav/common/datastore/file.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/file.py 2010-09-23 20:12:19 UTC (rev 6356)
+++ CalendarServer/trunk/txdav/common/datastore/file.py 2010-09-23 21:00:41 UTC (rev 6357)
@@ -49,6 +49,7 @@
from errno import EEXIST, ENOENT
from zope.interface import implements, directlyProvides
+import os
import uuid
ECALENDARTYPE = 0
@@ -92,15 +93,19 @@
self._transactionClass = CommonStoreTransaction
- def newTransaction(self, name='no name'):
+ def newTransaction(self, name='no name', migrating=False):
"""
Create a new transaction.
@see Transaction
"""
return self._transactionClass(
- self, name, self.enableCalendars,
- self.enableAddressBooks, self._notifierFactory
+ self,
+ name,
+ self.enableCalendars,
+ self.enableAddressBooks,
+ self._notifierFactory,
+ migrating,
)
@@ -148,8 +153,7 @@
_homeClass = {}
- def __init__(self, dataStore, name, enableCalendars, enableAddressBooks,
- notifierFactory):
+ def __init__(self, dataStore, name, enableCalendars, enableAddressBooks, notifierFactory, migrating=False):
"""
Initialize a transaction; do not call this directly, instead call
L{DataStore.newTransaction}.
@@ -169,6 +173,7 @@
self._homes[EADDRESSBOOKTYPE] = {}
self._notifications = {}
self._notifierFactory = notifierFactory
+ self._migrating = migrating
extraInterfaces = []
if enableCalendars:
@@ -376,7 +381,7 @@
) | set(
name
for name in self._path.listdir()
- if not name.startswith(".")
+ if not name.startswith(".") and self._path.child(name).isdir()
))
Modified: CalendarServer/trunk/txdav/common/datastore/sql.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/sql.py 2010-09-23 20:12:19 UTC (rev 6356)
+++ CalendarServer/trunk/txdav/common/datastore/sql.py 2010-09-23 21:00:41 UTC (rev 6357)
@@ -105,14 +105,15 @@
return []
- def newTransaction(self, label="unlabeled"):
+ def newTransaction(self, label="unlabeled", migrating=False):
return CommonStoreTransaction(
self,
self.connectionFactory(),
self.enableCalendars,
self.enableAddressBooks,
self.notifierFactory,
- label
+ label,
+ migrating,
)
class CommonStoreTransaction(object):
@@ -122,7 +123,7 @@
_homeClass = {}
- def __init__(self, store, connection, enableCalendars, enableAddressBooks, notifierFactory, label):
+ def __init__(self, store, connection, enableCalendars, enableAddressBooks, notifierFactory, label, migrating=False):
self._store = store
self._connection = connection
@@ -134,6 +135,7 @@
self._postCommitOperations = []
self._notifierFactory = notifierFactory
self._label = label
+ self._migrating = migrating
extraInterfaces = []
if enableCalendars:
Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema_v1.sql
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/sql_schema_v1.sql 2010-09-23 20:12:19 UTC (rev 6356)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema_v1.sql 2010-09-23 21:00:41 UTC (rev 6357)
@@ -207,7 +207,9 @@
MD5 char(32) not null,
CREATED timestamp default timezone('UTC', CURRENT_TIMESTAMP),
MODIFIED timestamp default timezone('UTC', CURRENT_TIMESTAMP),
- PATH varchar(1024) not null unique
+ PATH varchar(1024) not null,
+
+ unique(CALENDAR_OBJECT_RESOURCE_ID, PATH)
);
Modified: CalendarServer/trunk/txdav/common/datastore/util.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/util.py 2010-09-23 20:12:19 UTC (rev 6356)
+++ CalendarServer/trunk/txdav/common/datastore/util.py 2010-09-23 21:00:41 UTC (rev 6357)
@@ -98,7 +98,7 @@
for fileTxn, fileHome in eachFunc():
uid = fileHome.uid()
self.log_warn("Migrating %s UID %r" % (homeType, uid))
- sqlTxn = self.sqlStore.newTransaction()
+ sqlTxn = self.sqlStore.newTransaction(migrating=True)
sqlHome = destFunc(uid, sqlTxn)
yield migrateFunc(fileHome, sqlHome)
fileTxn.commit()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100923/f55b7cd9/attachment-0001.html>
More information about the calendarserver-changes
mailing list