[thunderbird-lightning/el6] Add upstream patch to fix caldav sync

Orion Poplawski orion at fedoraproject.org
Sat Dec 14 18:41:01 UTC 2013


commit a9c2f10c994d6a1123ff4ebab7990112c9e65d27
Author: Orion Poplawski <orion at nwra.com>
Date:   Mon Nov 4 11:20:58 2013 -0700

    Add upstream patch to fix caldav sync

 thunderbird-lightning-caldav.patch |  115 ++++++++++++++++++++++++++++++++++++
 thunderbird-lightning.spec         |    8 +++
 2 files changed, 123 insertions(+), 0 deletions(-)
---
diff --git a/thunderbird-lightning-caldav.patch b/thunderbird-lightning-caldav.patch
new file mode 100644
index 0000000..c0e8dbb
--- /dev/null
+++ b/thunderbird-lightning-caldav.patch
@@ -0,0 +1,115 @@
+# HG changeset patch
+# Parent f2f88ec0a46868d24358b8ef0e951a9e56b77c5a
+diff --git a/calendar/providers/caldav/calDavRequestHandlers.js b/calendar/providers/caldav/calDavRequestHandlers.js
+--- a/calendar/providers/caldav/calDavRequestHandlers.js
++++ b/calendar/providers/caldav/calDavRequestHandlers.js
+@@ -4,6 +4,7 @@
+ 
+ Components.utils.import("resource://calendar/modules/calUtils.jsm");
+ Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
++Components.utils.import("resource://gre/modules/Timer.jsm");
+ 
+ /**
+  * This is a handler for the etag request in calDavCalendar.js' getUpdatedItem.
+@@ -313,6 +314,7 @@
+     unhandledErrors : 0,
+     itemsReported: null,
+     itemsNeedFetching: null,
++    additionalSyncNeeded: false,
+ 
+     QueryInterface: XPCOMUtils.generateQI([
+         Components.interfaces.nsISAXContentHandler,
+@@ -497,6 +499,7 @@
+                                                    this.calendar,
+                                                    this.baseUri,
+                                                    this.newSyncToken,
++                                                   this.additionalSyncNeeded,
+                                                    null,
+                                                    this.changeLogListener)
+             multiget.doMultiGet();
+@@ -587,16 +590,26 @@
+                         // Etag mismatch, getting new/updated item.
+                         this.itemsNeedFetching.push(r.href);
+                     }
+-                // If the response element is still not handled, log an error
+-                // only if the content-type is text/calendar or the
+-                // response status is different than 404 not found.
+-                // We don't care about response elements
+-                // on non-calendar resources or whose status is not indicating
+-                // a deleted resource.
++                } else if (r.status.indexOf(" 507") > -1) {
++                    // webdav-sync says that if a 507 is encountered and the
++                    // url matches the request, the current token should be
++                    // saved and another request should be made. We don't
++                    // actually compare the URL, its too easy to get this
++                    // wrong.
++
++                    // The 507 doesn't mean the data received is invalid, so
++                    // continue processing.
++                    this.additionalSyncNeeded = true;
+                 } else if ((r.getcontenttype &&
+                             r.getcontenttype.substr(0,13) == "text/calendar") ||
+                            (r.status &&
+                             r.status.indexOf(" 404") == -1)) {
++                    // If the response element is still not handled, log an
++                    // error only if the content-type is text/calendar or the
++                    // response status is different than 404 not found.  We
++                    // don't care about response elements on non-calendar
++                    // resources or whose status is not indicating a deleted
++                    // resource.
+                     cal.WARN("CalDAV: Unexpected response, status: " + r.status + ", href: " + r.href);
+                     this.unhandledErrors++;
+                 } else {
+@@ -631,12 +644,15 @@
+  *                              array of un-encoded paths.
+  * @param aCalendar             The (unwrapped) calendar this request belongs to
+  * @param aBaseUri              The URI requested (i.e inbox or collection)
++ * @param aAdditionalSyncNeeded (optional) If true, the passed sync token is not the
++ *                                latest, another webdav sync run should be
++ *                                done after completion.
+  * @param aNewSyncToken         (optional) new Sync token to set if operation successful
+  * @param aListener             (optional) The listener to notify
+  * @param aChangeLogListener    (optional) for cached calendars, the listener to
+  *                                notify.
+  */
+-function multigetSyncHandler(aItemsNeedFetching, aCalendar, aBaseUri, aNewSyncToken, aListener, aChangeLogListener) {
++function multigetSyncHandler(aItemsNeedFetching, aCalendar, aBaseUri, aNewSyncToken, aAdditionalSyncNeeded, aListener, aChangeLogListener) {
+     this.calendar = aCalendar;
+     this.baseUri = aBaseUri;
+     this.listener = aListener;
+@@ -648,6 +664,7 @@
+     this._reader.errorHandler = this;
+     this._reader.parseAsync(null);
+     this.itemsNeedFetching = aItemsNeedFetching;
++    this.additionalSyncNeeded = aAdditionalSyncNeeded;
+ }
+ multigetSyncHandler.prototype = {
+     currentResponse: null,
+@@ -660,6 +677,7 @@
+     logXML: null,
+     unhandledErrors : 0,
+     itemsNeedFetching: null,
++    additionalSyncNeeded: false,
+ 
+     QueryInterface: XPCOMUtils.generateQI([
+         Components.interfaces.nsISAXContentHandler,
+@@ -754,8 +772,17 @@
+               cal.LOG("CalDAV: New webdav-sync Token: " + this.calendar.mWebdavSyncToken);
+             }
+ 
+-            this.calendar.finalizeUpdatedItems(this.changeLogListener,
+-                                               this.baseUri);
++            if (this.additionalSyncNeeded) {
++              setTimeout(() => {
++                let wds = new webDavSyncHandler(this.calendar,
++                                                this.baseUri,
++                                                this.changeLogListener);
++                wds.doWebDAVSync();
++              }, 0);
++            } else {
++              this.calendar.finalizeUpdatedItems(this.changeLogListener,
++                                                 this.baseUri);
++            }
+         }
+         if (!this._reader) {
+             // No reader means there was a request error. The error is already
diff --git a/thunderbird-lightning.spec b/thunderbird-lightning.spec
index da0cab9..dd29933 100644
--- a/thunderbird-lightning.spec
+++ b/thunderbird-lightning.spec
@@ -65,6 +65,10 @@ Patch107:       xulrunner-secarch.patch
 Patch206:       xulrunner-pagesize-ia64.patch
 
 
+# Fix caldav sync
+# https://bugzilla.mozilla.org/show_bug.cgi?id=930132
+Patch10:        thunderbird-lightning-caldav.patch
+
 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 BuildRequires:  nspr-devel >= %{nspr_version}
 BuildRequires:  nss-devel >= %{nss_version}
@@ -149,6 +153,7 @@ cd mozilla
 %patch206 -p2 -b .pagesize-ia64
 %patch103 -p2 -b .gc-sections
 cd ..
+%patch10 -p1 -b .caldav
 
 %{__rm} -f .mozconfig
 %{__cp} %{SOURCE10} .mozconfig
@@ -256,6 +261,9 @@ find $RPM_BUILD_ROOT -name \*.so | xargs chmod 0755
 #===============================================================================
 
 %changelog
+* Mon Nov 4 2013 Orion Poplawski <orion at cora.nwra.com> - 2.6.2-3
+- Add upstream patch to fix caldav sync
+
 * Wed Oct 30 2013 Jan Horak <jhorak at redhat.com> - 2.6.2-2
 - Update to 2.6.2
 


More information about the scm-commits mailing list