Permalink
Browse files

Merge migrate-merge branch.

  • Loading branch information...
1 parent f34bb21 commit d094a9d0c4c6f84b7b64628e783872a56951efe5 @glyph glyph committed Feb 16, 2012
@@ -927,7 +927,7 @@ def subServiceFactory(connectionFactory):
CachingFilePath(config.DocumentRoot),
PostDBImportService(config, store, mainService),
store, uid=overrideUID, gid=overrideGID,
- spawner=spawner,
+ spawner=spawner, merge=config.MergeUpgrades,
parallel=parallel
),
store, uid=overrideUID, gid=overrideGID,
@@ -76,6 +76,7 @@ def __init__(self):
super(UpgradeOptions, self).__init__()
self.upgradeers = []
self.outputName = '-'
+ self.merge = False
def opt_output(self, filename):
@@ -87,6 +88,16 @@ def opt_output(self, filename):
opt_o = opt_output
+ def opt_merge(self):
+ """
+ Rather than skipping homes that exist on the filesystem but not in the
+ database, merge their data into the existing homes.
+ """
+ self.merge = True
+
+ opt_m = opt_merge
+
+
def openOutput(self):
"""
Open the appropriate output file based on the '--output' option.
@@ -138,6 +149,7 @@ def main(argv=sys.argv, stderr=sys.stderr, reactor=None):
"""
Do the export.
"""
+ from twistedcaldav.config import config
if reactor is None:
from twisted.internet import reactor
@@ -154,8 +166,12 @@ def main(argv=sys.argv, stderr=sys.stderr, reactor=None):
(e))
sys.exit(1)
+ if options.merge:
+ def setMerge(data):
+ data.MergeUpgrades = True
+ config.addPostUpdateHooks([setMerge])
+
def makeService(store):
- from twistedcaldav.config import config
return UpgraderService(store, options, output, reactor, config)
def onlyUpgradeEvents(event):
@@ -550,6 +550,11 @@
# the future, hopefully all relevant
# upgrades - in parallel in subprocesses.
+ "MergeUpgrades": False, # During the upgrade phase of startup, rather than
+ # skipping homes found both on the filesystem and in
+ # the database, merge the data from the filesystem
+ # into the database homes.
+
"EnableDefaultAlarms" : True, # Support for default alarms generated by the server
# CardDAV Features
@@ -151,19 +151,49 @@ def remove(self):
yield self._cacher.delete(str(self._ownerUID))
+
@inlineCallbacks
def hasCalendarResourceUIDSomewhereElse(self, uid, ok_object, type):
-
+ """
+ Determine if this calendar home contains any calendar objects which
+ would potentially conflict with the given UID for scheduling purposes.
+
+ @param uid: The UID to search for.
+ @type uid: C{str}
+
+ @param ok_object: a calendar object with the given UID, that doesn't
+ count as a potential conflict (since, for example, it is the one
+ being updated). May be C{None} if all objects potentially count.
+ @type ok_object: L{CalendarObject} or C{NoneType}
+
+ @param type: a string, indicating the mode to check for conflicts. If
+ this is the string "schedule", then we are checking for potential
+ conflicts with a new scheduled calendar object, which will conflict
+ with any calendar object matching the given C{uid} in the home.
+ Otherwise, (if this is the string "calendar") we are checking for
+ conflicts with a new unscheduled calendar object, which will
+ conflict only with other scheduled objects.
+ @type type: C{str}
+
+ @return: a L{Deferred} which fires with C{True} if there is a conflict
+ and C{False} if not.
+ """
+ # FIXME: this should be documented on the interface; it should also
+ # refer to calendar *object* UIDs, since calendar *resources* are an
+ # HTTP protocol layer thing, not a data store thing. (See also
+ # objectResourcesWithUID.)
objectResources = (yield self.objectResourcesWithUID(uid, ("inbox",)))
for objectResource in objectResources:
if ok_object and objectResource._resourceID == ok_object._resourceID:
continue
- matched_type = "schedule" if objectResource.isScheduleObject else "calendar"
+ matched_type = ("schedule" if objectResource.isScheduleObject
+ else "calendar")
if type == "schedule" or matched_type == "schedule":
returnValue(True)
returnValue(False)
+
@inlineCallbacks
def getCalendarResourcesForUID(self, uid, allow_shared=False):
Oops, something went wrong.

0 comments on commit d094a9d

Please sign in to comment.