[CalendarServer-changes] [9387] CalendarServer/trunk/contrib/migration
source_changes at macosforge.org
source_changes at macosforge.org
Tue Jun 26 16:59:09 PDT 2012
Revision: 9387
http://trac.macosforge.org/projects/calendarserver/changeset/9387
Author: sagen at apple.com
Date: 2012-06-26 16:59:09 -0700 (Tue, 26 Jun 2012)
Log Message:
-----------
Deal with pre-existing Data/Documents directory
Modified Paths:
--------------
CalendarServer/trunk/contrib/migration/calendarmigrator.py
CalendarServer/trunk/contrib/migration/test/test_migrator.py
Modified: CalendarServer/trunk/contrib/migration/calendarmigrator.py
===================================================================
--- CalendarServer/trunk/contrib/migration/calendarmigrator.py 2012-06-26 18:31:28 UTC (rev 9386)
+++ CalendarServer/trunk/contrib/migration/calendarmigrator.py 2012-06-26 23:59:09 UTC (rev 9387)
@@ -659,11 +659,12 @@
if not diskAccessor.exists(newDataRoot):
diskAccessor.mkdir(newDataRoot)
newDocumentRoot = os.path.join(newDataRootValue, "Documents")
- if diskAccessor.exists(os.path.join(oldServerRootValue, "Documents")):
- diskAccessor.rename(os.path.join(oldServerRootValue, "Documents"),
- newDocumentRoot)
- else:
- diskAccessor.mkdir(newDocumentRoot)
+ if not diskAccessor.exists(newDocumentRoot):
+ if diskAccessor.exists(os.path.join(oldServerRootValue, "Documents")):
+ diskAccessor.rename(os.path.join(oldServerRootValue, "Documents"),
+ newDocumentRoot)
+ else:
+ diskAccessor.mkdir(newDocumentRoot)
elif diskAccessor.exists(absolutePathWithRoot(sourceRoot, oldServerRootValue)):
log("Copying calendar server root: %s" % (newServerRoot,))
diskAccessor.ditto(
@@ -674,19 +675,25 @@
if not diskAccessor.exists(newDataRoot):
diskAccessor.mkdir(newDataRoot)
newDocumentRoot = os.path.join(newDataRoot, "Documents")
- if diskAccessor.exists(os.path.join(newServerRoot, "Documents")):
- log("Moving Documents into Data root: %s" % (newDataRoot,))
- diskAccessor.rename(os.path.join(newServerRoot, "Documents"),
- newDocumentRoot)
- else:
- diskAccessor.mkdir(newDocumentRoot)
+ if not diskAccessor.exists(newDocumentRoot):
+ if diskAccessor.exists(os.path.join(newServerRoot, "Documents")):
+ log("Moving Documents into Data root: %s" % (newDataRoot,))
+ diskAccessor.rename(os.path.join(newServerRoot, "Documents"),
+ newDocumentRoot)
+ else:
+ diskAccessor.mkdir(newDocumentRoot)
else:
- log("Creating new calendar server root: %s" % (newServerRoot,))
- diskAccessor.mkdir(newServerRoot)
+ if not diskAccessor.exists(newServerRoot):
+ log("Creating new calendar server root: %s" % (newServerRoot,))
+ diskAccessor.mkdir(newServerRoot)
newDataRoot = os.path.join(newServerRoot, "Data")
- diskAccessor.mkdir(newDataRoot)
+ if not diskAccessor.exists(newDataRoot):
+ log("Creating new data root: %s" % (newDataRoot,))
+ diskAccessor.mkdir(newDataRoot)
newDocumentRoot = os.path.join(newDataRoot, "Documents")
- diskAccessor.mkdir(newDocumentRoot)
+ if not diskAccessor.exists(newDocumentRoot):
+ log("Creating new document root: %s" % (newDocumentRoot,))
+ diskAccessor.mkdir(newDocumentRoot)
else: # 10.8 -> 10.8
Modified: CalendarServer/trunk/contrib/migration/test/test_migrator.py
===================================================================
--- CalendarServer/trunk/contrib/migration/test/test_migrator.py 2012-06-26 18:31:28 UTC (rev 9386)
+++ CalendarServer/trunk/contrib/migration/test/test_migrator.py 2012-06-26 23:59:09 UTC (rev 9387)
@@ -1284,6 +1284,71 @@
),
(
+ "Lion -> Mountain Lion Migration, all in default locations, with existing Data/Documents",
+ {
+ "/Library/Server/Previous/private/etc/caldavd/caldavd.plist" : """
+ <plist version="1.0">
+ <dict>
+ <key>ServerRoot</key>
+ <string>/Library/Server/Calendar and Contacts</string>
+ <key>DocumentRoot</key>
+ <string>Documents</string>
+ <key>DataRoot</key>
+ <string>Data</string>
+ <key>UserName</key>
+ <string>calendar</string>
+ <key>GroupName</key>
+ <string>calendar</string>
+ </dict>
+ </plist>
+ """,
+ "/Volumes/new/private/etc/caldavd/caldavd.plist" : """
+ <plist version="1.0">
+ <dict>
+ <key>ServerRoot</key>
+ <string>/Library/Server/Calendar and Contacts</string>
+ <key>DocumentRoot</key>
+ <string>Documents</string>
+ <key>DataRoot</key>
+ <string>Data</string>
+ <key>UserName</key>
+ <string>calendar</string>
+ <key>GroupName</key>
+ <string>calendar</string>
+ </dict>
+ </plist>
+ """,
+
+ "/Library/Server/Previous/Library/Server/Calendar and Contacts/Documents/" : True,
+ "/Library/Server/Previous/Library/Server/Calendar and Contacts/Data/" : True,
+ "/Volumes/new/Library/Server/Calendar and Contacts/" : True,
+ "/Volumes/new/Library/Server/Calendar and Contacts/Data" : True,
+ "/Volumes/new/Library/Server/Calendar and Contacts/Data/Documents" : True,
+ "/Volumes/new/Library/Server/Calendar and Contacts/Documents" : True,
+ },
+ ( # args
+ "/Library/Server/Previous", # sourceRoot
+ "/Volumes/new", # targetRoot
+ "10.7.3", # sourceVersion
+ "/Library/Server/Calendar and Contacts", # oldServerRootValue
+ "Documents", # oldCalDocumentRootValue
+ "Data", # oldCalDataRootValue
+ None, # oldABDocumentRootValue
+ FakeUser.pw_uid, FakeGroup.gr_gid, # user id, group id
+ ),
+ ( # expected return values
+ "/Volumes/new/Library/Server/Calendar and Contacts",
+ "/Library/Server/Calendar and Contacts",
+ "Data"
+ ),
+ [
+ ('ditto', '/Library/Server/Previous/Library/Server/Calendar and Contacts', '/Volumes/new/Library/Server/Calendar and Contacts'),
+ ('chown-recursive', '/Volumes/new/Library/Server/Calendar and Contacts', FakeUser.pw_uid, FakeGroup.gr_gid),
+ ]
+ ),
+
+
+ (
"Lion -> Mountain Lion Migration, external ServerRoot",
{
"/Library/Server/Previous/private/etc/caldavd/caldavd.plist" : """
@@ -1345,7 +1410,8 @@
('chown-recursive', '/Volumes/new/Library/Server/Calendar and Contacts', FakeUser.pw_uid, FakeGroup.gr_gid),
]
),
-(
+
+ (
"Mountain Lion -> Mountain Lion Migration, all in default locations",
{
"/Library/Server/Previous/private/etc/caldavd/caldavd.plist" : """
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20120626/4d785e87/attachment.html>
More information about the calendarserver-changes
mailing list