[CalendarServer-changes] [14705] CalendarServer/trunk/twistedcaldav

source_changes at macosforge.org source_changes at macosforge.org
Fri Apr 24 10:09:24 PDT 2015


Revision: 14705
          http://trac.calendarserver.org//changeset/14705
Author:   cdaboo at apple.com
Date:     2015-04-24 10:09:23 -0700 (Fri, 24 Apr 2015)
Log Message:
-----------
Fix issues where DataRoot timezone data was not being updated if the version.txt file was missing.

Modified Paths:
--------------
    CalendarServer/trunk/twistedcaldav/test/test_timezones.py
    CalendarServer/trunk/twistedcaldav/timezones.py

Modified: CalendarServer/trunk/twistedcaldav/test/test_timezones.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/test/test_timezones.py	2015-04-24 16:56:08 UTC (rev 14704)
+++ CalendarServer/trunk/twistedcaldav/test/test_timezones.py	2015-04-24 17:09:23 UTC (rev 14705)
@@ -279,6 +279,24 @@
         self.assertEqual(str(pkg_tz), str(copy_tz))
 
 
+    def test_copyPackage_missingVersion(self):
+        """
+        Test that tz data is updated if the version is missing.
+        """
+
+        self.patch(config, "UsePackageTimezones", False)
+        TimezoneCache.clear()
+        TimezoneCache.create()
+
+        self.assertTrue(os.path.exists(os.path.join(config.DataRoot, "zoneinfo")))
+        self.assertTrue(os.path.exists(os.path.join(config.DataRoot, "zoneinfo", "version.txt")))
+        os.remove(os.path.join(config.DataRoot, "zoneinfo", "version.txt"))
+        self.assertFalse(os.path.exists(os.path.join(config.DataRoot, "zoneinfo", "version.txt")))
+
+        TimezoneCache.create()
+        self.assertTrue(os.path.exists(os.path.join(config.DataRoot, "zoneinfo", "version.txt")))
+
+
     def test_copyPackage_Concurrency(self):
         """
         Test that concurrent copying of the tz package works.

Modified: CalendarServer/trunk/twistedcaldav/timezones.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/timezones.py	2015-04-24 16:56:08 UTC (rev 14704)
+++ CalendarServer/trunk/twistedcaldav/timezones.py	2015-04-24 17:09:23 UTC (rev 14705)
@@ -104,7 +104,7 @@
         try:
             return open(os.path.join(dbpath, "version.txt")).read().strip()
         except IOError:
-            return TimezoneCache.IANA_VERSION_PREFIX + "Unknown"
+            return ""
 
 
     class FilteredFilePath(FilePath):
@@ -134,7 +134,7 @@
             # Check if pkg is more recent and copy over
             pkgversion = TimezoneCache.getTZVersion(TimezoneCache._getPackageDBPath())
             dbversion = TimezoneCache.getTZVersion(dbpath.path)
-            if pkgversion > dbversion:
+            if not dbversion or pkgversion > dbversion:
                 dbpath.remove()
                 TimezoneCache.copyPackage("Updating")
             else:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20150424/1e8c45a4/attachment.html>


More information about the calendarserver-changes mailing list