Fix bug 700637 - this.mItemInfoCache[aNewItem.id] is null using caldav cached calendar. r=release,a=philipp
authorPhilipp Kewisch <mozilla@kewis.ch>
Mon, 23 Jan 2012 00:13:25 +0100
changeset 10117 d68585c44d7352d83aafdfb3bdcf93f48aa2fbbd
parent 10116 e2828114a2d94d72de9898e75b4d1dda8058fc33
child 10118 ee492eaff0e3301971b2e6fdcdf44efbf9cda57d
push idunknown
push userunknown
push dateunknown
reviewersrelease, philipp
bugs700637
Fix bug 700637 - this.mItemInfoCache[aNewItem.id] is null using caldav cached calendar. r=release,a=philipp
calendar/providers/storage/calStorageCalendar.js
--- a/calendar/providers/storage/calStorageCalendar.js
+++ b/calendar/providers/storage/calStorageCalendar.js
@@ -2047,17 +2047,17 @@ calStorageCalendar.prototype = {
             params[entryname + "_tz"] = null;
         }
     },
 
     flushItem: function cSC_flushItem(item, olditem) {
         ASSERT(!item.recurrenceId, "no parent item passed!", true);
 
         try {
-            this.deleteItemById(olditem ? olditem.id : item.id);
+            this.deleteItemById(olditem ? olditem.id : item.id, !!olditem);
             this.acquireTransaction();
             this.writeItem(item, olditem);
         } catch (e) {
             this.releaseTransaction(e);
             throw e;
         }
         this.releaseTransaction();
 
@@ -2434,29 +2434,31 @@ calStorageCalendar.prototype = {
 
         return CAL_ITEM_FLAG.HAS_ALARMS;
     },
 
     /**
      * Deletes the item with the given item id.
      *
      * @param aID           The id of the item to delete.
+     * @param aIsModify     If true, then leave in metadata for the item
      */
-    deleteItemById: function cSC_deleteItemById(aID) {
+    deleteItemById: function cSC_deleteItemById(aID, aIsModify) {
         this.acquireTransaction();
         try {
             this.mDeleteAttendees(aID, this.id);
             this.mDeleteProperties(aID, this.id);
             this.mDeleteRecurrence(aID, this.id);
             this.mDeleteEvent(aID, this.id);
             this.mDeleteTodo(aID, this.id);
             this.mDeleteAttachments(aID, this.id);
             this.mDeleteRelations(aID, this.id);
-            this.mDeleteMetaData(aID, this.id);
-            //this.mDeleteAllMetaData(aID, this.id);
+            if (!aIsModify) {
+                this.mDeleteMetaData(aID, this.id);
+            }
             this.mDeleteAlarms(aID, this.id);
         } catch (e) {
             this.releaseTransaction(e);
             throw e;
         }
         this.releaseTransaction();
 
         delete this.mItemCache[aID];
@@ -2494,24 +2496,21 @@ calStorageCalendar.prototype = {
 
         this.mDeleteMetaData(id, this.id);
         try {
             this.prepareStatement(this.mInsertMetaData);
             var sp = this.mInsertMetaData.params;
             sp.item_id = id;
             sp.value = value;
             this.mInsertMetaData.execute();
-        } catch (e) {
+        } catch (e if e.result == Components.results.NS_ERROR_ILLEGAL_VALUE) {
             // The storage service throws an NS_ERROR_ILLEGAL_VALUE in
             // case pval is something complex (i.e not a string or
             // number). Swallow this error, leaving the value empty.
-            if (e.result != Components.results.NS_ERROR_ILLEGAL_VALUE) {
-                this.logError("Error setting metadata for id " + id + "!", e);
-                throw e;
-            }
+            this.logError("Error setting metadata for id " + id + "!", e);
         } finally {
             this.mInsertMetaData.reset();
         }
     },
 
     deleteMetaData: function cSC_deleteMetaData(id) {
         this.mDeleteMetaData(id, this.id);
     },