Skip to content

Commit 6732484

Browse files
committed
[buteo-sync-plugin-caldav] Retrieve full event after PUT when the etag is missing.
1 parent 7855ede commit 6732484

3 files changed

Lines changed: 16 additions & 38 deletions

File tree

src/notebooksyncagent.cpp

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -628,8 +628,7 @@ void NotebookSyncAgent::finalizeSendingLocalChanges()
628628
Report *report = new Report(mNetworkManager, mSettings);
629629
mRequests.insert(report);
630630
connect(report, SIGNAL(finished()), this, SLOT(additionalReportRequestFinished()));
631-
report->multiGetEtags(mRemoteCalendarPath, mSentUids.keys());
632-
return;
631+
report->multiGetEvents(mRemoteCalendarPath, mSentUids.keys());
633632
} else {
634633
emitFinished(Buteo::SyncResults::NO_ERROR);
635634
}
@@ -642,30 +641,22 @@ void NotebookSyncAgent::additionalReportRequestFinished()
642641
// The server did not originally respond with the update ETAG values after
643642
// our initial PUT/UPDATE so we had to do an addition report request.
644643
// This response will contain the new ETAG values for any resource we
645-
// upsynced (ie, a local modification/addition).
644+
// upsynced (ie, a local modification/addition) and also the incidence
645+
// as it may have been modified by the server.
646646

647647
Report *report = qobject_cast<Report*>(sender());
648648
mRequests.remove(report);
649649
report->deleteLater();
650650

651651
if (report->errorCode() == Buteo::SyncResults::NO_ERROR) {
652652
LOG_DEBUG("Additional report request finished: received:"
653-
<< report->receivedCalendarResources().length() << "iCal blobs containing a total of"
654653
<< report->receivedCalendarResources().count() << "incidences");
655-
for (QList<Reader::CalendarResource>::ConstIterator
656-
it = report->receivedCalendarResources().constBegin();
657-
it != report->receivedCalendarResources().constEnd(); ++it) {
658-
if (mSentUids.contains(it->href)) {
659-
updateHrefETag(mSentUids.take(it->href), it->href, it->etag);
660-
}
661-
}
662-
LOG_DEBUG("Remains" << mSentUids.count() << "uris not updated.");
654+
mReceivedCalendarResources += report->receivedCalendarResources();
663655
emitFinished(Buteo::SyncResults::NO_ERROR);
664-
return;
656+
} else {
657+
LOG_WARNING("Additional report request finished with error, aborting sync of notebook:" << mRemoteCalendarPath);
658+
emitFinished(report->errorCode(), report->errorString());
665659
}
666-
667-
LOG_WARNING("Additional report request finished with error, aborting sync of notebook:" << mRemoteCalendarPath);
668-
emitFinished(report->errorCode(), report->errorString());
669660
}
670661

671662
bool NotebookSyncAgent::applyRemoteChanges()
@@ -1015,7 +1006,14 @@ void NotebookSyncAgent::updateIncidence(KCalCore::Incidence::Ptr incidence,
10151006
}
10161007

10171008
storedIncidence->endUpdates();
1018-
storedIncidence->setLastModified(incidence->lastModified());
1009+
// Avoid spurious detections of modified incidences
1010+
// by ensuring that the received last modification date time
1011+
// is previous to the sync date time.
1012+
if (incidence->lastModified() < mNotebookSyncedDateTime) {
1013+
storedIncidence->setLastModified(incidence->lastModified());
1014+
} else {
1015+
storedIncidence->setLastModified(mNotebookSyncedDateTime.addSecs(-2));
1016+
}
10191017
}
10201018
incidence->setUid(storedIncidence->uid());
10211019
}

src/report.cpp

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -109,30 +109,14 @@ void Report::sendCalendarQuery(const QString &remoteCalendarPath,
109109
}
110110

111111
void Report::multiGetEvents(const QString &remoteCalendarPath, const QStringList &eventHrefList)
112-
{
113-
FUNCTION_CALL_TRACE;
114-
sendMultiQuery(remoteCalendarPath, eventHrefList, true);
115-
}
116-
117-
void Report::multiGetEtags(const QString &remoteCalendarPath, const QStringList &eventHrefList)
118-
{
119-
FUNCTION_CALL_TRACE;
120-
sendMultiQuery(remoteCalendarPath, eventHrefList, false);
121-
}
122-
123-
void Report::sendMultiQuery(const QString &remoteCalendarPath, const QStringList &eventHrefList, bool getCalendarData)
124112
{
125113
FUNCTION_CALL_TRACE;
126114
if (eventHrefList.isEmpty()) {
127115
return;
128116
}
129117

130118
QByteArray requestData = "<c:calendar-multiget xmlns:d=\"DAV:\" xmlns:c=\"urn:ietf:params:xml:ns:caldav\">" \
131-
"<d:prop><d:getetag />";
132-
if (getCalendarData) {
133-
requestData += "<c:calendar-data />";
134-
}
135-
requestData += "</d:prop>";
119+
"<d:prop><d:getetag /><c:calendar-data /></d:prop>";
136120
for (const QString &eventHref : eventHrefList) {
137121
requestData.append("<d:href>");
138122
requestData.append(eventHref.toUtf8());

src/report.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ class Report : public Request
4747
const QDateTime &fromDateTime = QDateTime(),
4848
const QDateTime &toDateTime = QDateTime());
4949
void multiGetEvents(const QString &remoteCalendarPath, const QStringList &eventHrefList);
50-
void multiGetEtags(const QString &remoteCalendarPath, const QStringList &eventHrefList);
5150

5251
const QList<Reader::CalendarResource>& receivedCalendarResources() const;
5352

@@ -60,9 +59,6 @@ private Q_SLOTS:
6059
const QDateTime &fromDateTime,
6160
const QDateTime &toDateTime,
6261
bool getCalendarData);
63-
void sendMultiQuery(const QString &remoteCalendarPath,
64-
const QStringList &uris,
65-
bool getCalendarData);
6662
QString mRemoteCalendarPath;
6763
QList<Reader::CalendarResource> mReceivedResources;
6864
};

0 commit comments

Comments
 (0)