[CalendarServer-changes] [4380] CalendarServer/trunk/twistedcaldav/upgrade.py

source_changes at macosforge.org source_changes at macosforge.org
Thu Jun 25 14:04:10 PDT 2009


Revision: 4380
          http://trac.macosforge.org/projects/calendarserver/changeset/4380
Author:   sagen at apple.com
Date:     2009-06-25 14:04:10 -0700 (Thu, 25 Jun 2009)
Log Message:
-----------
If proxy db rename (move) fails, copy it instead.

Modified Paths:
--------------
    CalendarServer/trunk/twistedcaldav/upgrade.py

Modified: CalendarServer/trunk/twistedcaldav/upgrade.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/upgrade.py	2009-06-25 17:52:06 UTC (rev 4379)
+++ CalendarServer/trunk/twistedcaldav/upgrade.py	2009-06-25 21:04:10 UTC (rev 4380)
@@ -26,7 +26,7 @@
 from twistedcaldav.ical import Component
 from twistedcaldav import caldavxml
 from calendarserver.tools.util import getDirectory
-import xattr, os, zlib, hashlib, datetime, pwd, grp
+import xattr, os, zlib, hashlib, datetime, pwd, grp, shutil
 from zlib import compress
 from cPickle import loads as unpickle, UnpicklingError
 
@@ -218,7 +218,13 @@
         try:
             if not os.path.exists(config.DataRoot):
                 makeDirsUserGroup(config.DataRoot, uid=uid, gid=gid)
-            os.rename(oldDbPath, newDbPath)
+            try:
+                os.rename(oldDbPath, newDbPath)
+            except OSError:
+                # Can't rename, must copy/delete
+                shutil.copy2(oldDbPath, newDbPath)
+                os.remove(oldDbPath)
+
         except Exception, e:
             raise UpgradeError(
                 "Upgrade Error: unable to move the old calendar user proxy database at '%s' to '%s' due to %s."
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20090625/b20909b1/attachment.html>


More information about the calendarserver-changes mailing list