Bug 827078 - Items deleted server-side still appear in cached CalDAV calendars - part 1: preserve meta-data when items added. r=redDragon, a=mmecca
authorMatthew Mecca <matthew.mecca@gmail.com>
Tue, 05 Feb 2013 00:21:16 -0500
changeset 13617 3c20b0923d6db5ad01e0a8d49b522d527ff7f0fd
parent 13616 7c6897b7efac220e5e5b7baddb44bddd3eebc16f
child 13618 b1d4f46d856f7ef0209914a8b82e9b63ab92598b
push id33
push usermatthew.mecca@gmail.com
push dateFri, 08 Feb 2013 22:30:17 +0000
reviewersredDragon, mmecca
bugs827078
Bug 827078 - Items deleted server-side still appear in cached CalDAV calendars - part 1: preserve meta-data when items added. r=redDragon, a=mmecca
calendar/providers/storage/calStorageCalendar.js
--- a/calendar/providers/storage/calStorageCalendar.js
+++ b/calendar/providers/storage/calStorageCalendar.js
@@ -436,17 +436,17 @@ calStorageCalendar.prototype = {
         if (aItem.id == null) {
             // is this an error?  Or should we generate an IID?
             aItem.id = cal.getUUID();
         } else {
             var olditem = this.getItemById(aItem.id);
             if (olditem) {
                 if (this.relaxedMode) {
                     // we possibly want to interact with the user before deleting
-                    this.deleteItemById(aItem.id);
+                    this.deleteItemById(aItem.id, true);
                 } else {
                     this.notifyOperationComplete(aListener,
                                                  Components.interfaces.calIErrors.DUPLICATE_ID,
                                                  Components.interfaces.calIOperationListener.ADD,
                                                  aItem.id,
                                                  "ID already exists for addItem");
                     return;
                 }
@@ -567,17 +567,17 @@ calStorageCalendar.prototype = {
             if (aOldItem.generation == modifiedItem.generation) { // has been cloned and modified
                 // Only take care of incrementing the generation if relaxed mode is
                 // off. Users of relaxed mode need to take care of this themselves.
                 modifiedItem.generation += 1;
             }
         }
 
         modifiedItem.makeImmutable();
-        this.flushItem (modifiedItem, aOldItem);
+        this.flushItem(modifiedItem, aOldItem);
         this.setOfflineJournalFlag(aNewItem, oldOfflineFlag);
 
         this.notifyOperationComplete(aListener,
                                      Components.results.NS_OK,
                                      Components.interfaces.calIOperationListener.MODIFY,
                                      modifiedItem.id,
                                      modifiedItem);
 
@@ -2072,17 +2072,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, !!olditem);
+            this.deleteItemById(olditem ? olditem.id : item.id, true);
             this.acquireTransaction();
             this.writeItem(item, olditem);
         } catch (e) {
             this.releaseTransaction(e);
             throw e;
         }
         this.releaseTransaction();
 
@@ -2516,17 +2516,17 @@ calStorageCalendar.prototype = {
     //
     // calISyncWriteCalendar interface
     //
 
     setMetaData: function cSC_setMetaData(id, value) {
         this.executeItemStatement(this.mDeleteMetaData, "item_id", id);
         try {
             this.prepareStatement(this.mInsertMetaData);
-            var sp = this.mInsertMetaData.params;
+            let sp = this.mInsertMetaData.params;
             sp.item_id = id;
             sp.value = value;
             this.mInsertMetaData.executeStep();
         } 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.
             this.logError("Error setting metadata for id " + id + "!", e);