Bug 1187072 - Cache support gets reset disabled for network calendars in calendar property dialog;r+a=philipp
authorMakeMyDay <makemyday@gmx-topmail.de>
Fri, 07 Aug 2015 11:32:31 +0200
changeset 22849 46f923a77f83e2c49ef6d9d19e9cd7f3b91af419
parent 22848 0c4d96a60e8792dd4aa9bf516fcc52902367b350
child 22850 dd5111841d45745b1c275ad6e0658889dcc3c5d9
push id1443
push usermbanner@mozilla.com
push dateMon, 10 Aug 2015 18:31:17 +0000
treeherdercomm-beta@8fe07d686c22 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1187072
Bug 1187072 - Cache support gets reset disabled for network calendars in calendar property dialog;r+a=philipp
calendar/base/content/calendar-management.js
calendar/base/src/calCalendarManager.js
--- a/calendar/base/content/calendar-management.js
+++ b/calendar/base/content/calendar-management.js
@@ -85,16 +85,25 @@ function loadCalendarManager() {
 
     // Initialize our composite observer
     compositeCalendar.addObserver(compositeObserver);
 
     // Create the home calendar if no calendar exists.
     let calendars = cal.getCalendarManager().getCalendars({});
     if (!calendars.length) {
         initHomeCalendar();
+    } else {
+        // migration code to make sure calendars, which do not support caching have cache enabled
+        // required to further clean up on top of bug 1182264
+        for (let calendar of calendars) {
+            if (calendar.getProperty("cache.supported") === false &&
+                calendar.getProperty("cache.enabled") === true) {
+                calendar.deleteProperty("cache.enabled");
+            }
+        }
     }
 }
 
 /**
  * Creates the initial "Home" calendar if no calendar exists.
  */
 function initHomeCalendar() {
     let calMgr = cal.getCalendarManager();
--- a/calendar/base/src/calCalendarManager.js
+++ b/calendar/base/src/calCalendarManager.js
@@ -832,18 +832,20 @@ calMgrCalendarObserver.prototype = {
 
     changeCalendarCache: function(aCalendar, aName, aValue, aOldValue) {
         const cICM = Components.interfaces.calICalendarManager;
         aOldValue = aOldValue || false;
         aValue = aValue || false;
 
         // hack for bug 1182264 to deal with calendars, which have set cache.enabled, but in fact do
         // not support caching (like storage calendars) - this also prevents enabling cache again
-        if (!aCalendar.getProperty('cache.supported')) {
-            aCalendar.setProperty("cache.enabled", false);
+        if (aCalendar.getProperty("cache.supported") === false) {
+            if (aCalendar.getProperty("cache.enabled") === true) {
+                aCalendar.deleteProperty("cache.enabled");
+            }
             return;
         }
 
         if (aOldValue != aValue) {
             // Try to find the current sort order
             let sortOrderPref = Preferences.get("calendar.list.sortOrder", "").split(" ");
             let initialSortOrderPos = null;
             for (let i = 0; i < sortOrderPref.length; ++i) {