Commit c1870c36 authored by Chris Adams's avatar Chris Adams

[nemo-qml-plugin-calendar] Purge deleted local events. Contributes to JB#52656

Local calendar events are never synced anywhere, so we can purge them
rather than merely marking them as deleted, in order to avoid them
remaining in the database (along with their reminder alarms).

Note that the purgeDeletedIncidences() call must occur after the call
to ExtendedStorage::save() in order to work correctly.
parent 174558df
......@@ -193,11 +193,17 @@ void CalendarWorker::save()
if (!mDeletedEvents.isEmpty()) {
for (const QPair<QString, QDateTime> &pair: mDeletedEvents) {
KCalendarCore::Event::Ptr event = mCalendar->deletedEvent(pair.first, pair.second);
if (!needSendCancellation(event)) {
continue;
if (needSendCancellation(event)) {
event->setStatus(KCalendarCore::Incidence::StatusCanceled);
mKCal::ServiceHandler::instance().sendUpdate(event, QString(), mCalendar, mStorage);
}
// if the event was stored in a local (non-synced) notebook, purge it.
const QString notebookUid = mCalendar->notebook(event);
const mKCal::Notebook::Ptr notebook = mStorage->notebook(notebookUid);
if (!notebook.isNull() && notebook->pluginName().isEmpty() && notebook->account().isEmpty()
&& !mStorage->purgeDeletedIncidences(KCalendarCore::Incidence::List() << event)) {
qWarning() << "Failed to purge deleted event " << event->uid() << " from local calendar " << notebookUid;
}
event->setStatus(KCalendarCore::Incidence::StatusCanceled);
mKCal::ServiceHandler::instance().sendUpdate(event, QString(), mCalendar, mStorage);
}
mDeletedEvents.clear();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment