khal
khal copied to clipboard
Importing updated event breaks database due to duplicate UID
When someone updates a calendar event, and I import the resulting ICS "updated invitation", then khal inserts a new record, causing a duplicate UID conflict:
error: madduck_calendar/calendar.ics: Storage "madduck_calendar_local/calendar.ics" contains multiple items with the same UID or even content. Vdirsyncer will now abort the synchronization of this collection, because the fix for this is not clear; It could be the result of a badly behaving server. You can try running:
error:
error: vdirsyncer repair madduck_calendar_local/calendar.ics
error:
error: But make sure to have a backup of your data in some form. The offending hrefs are:
error:
error: '35f41be794204ef89e5e055bdf86b800.ics'
error: '6448594d644f4976babb5d1f4cf6e2b0.ics'
It should really check if there's already an event with the UID, and if so, then update it.
For the record, repair fixes the issue.
agree, this is a bug.
Hmm, I cannot reproduce this behaviour. How do you import the updated event?
I use --batch, but of course currently everything works like it should, and I cannot reproduce this bug. I'll close it for now until I have more info.
I was able to reproduce this bug. Please find attached an event I received, as well as an update to the event. The UID is the same in both, the only changes are in timestamps and SEQUENCE:
--- /tmp/event.ics 2019-09-18 08:32:12.971330510 +0200
+++ /tmp/update.ics 2019-09-18 08:32:33.011330433 +0200
@@ -4,9 +4,9 @@
CALSCALE:GREGORIAN
METHOD:REQUEST
BEGIN:VEVENT
-DTSTART:20190923T080000Z
-DTEND:20190923T092000Z
-DTSTAMP:20190913T071201Z
+DTSTART:20190925T054500Z
+DTEND:20190925T071500Z
+DTSTAMP:20190918T060953Z
ORGANIZER:mailto:[email protected]
UID:[email protected]
ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=
@@ -15,8 +15,8 @@
;X-NUM-GUESTS=0:mailto:[email protected]
X-MICROSOFT-CDO-OWNERAPPTID:708245822
CREATED:20190913T071155Z
-LAST-MODIFIED:20190913T071155Z
-SEQUENCE:0
+LAST-MODIFIED:20190918T060950Z
+SEQUENCE:2
STATUS:CONFIRMED
SUMMARY:Coffee Martin - Manuel
TRANSP:OPAQUE
Here is what happens:
% khal import -a madduck /tmp/event.ics
2019-09-23 10:00-2019-09-23 11:20 Coffee Martin - Manuel
Do you want to import this event into `madduck`? [y/N]: y
% vdirsyncer -vINFO sync madduck_calendar/calendar
Syncing madduck_calendar/calendar
Copying (uploading) item [email protected] to madduck_calendar_remote/calendar
% khal import -a madduck /tmp/update.ics
2019-09-25 07:45-2019-09-25 09:15 Coffee Martin - Manuel
Do you want to import this event into `madduck`? [y/N]: y
% vdirsyncer -vINFO sync madduck_calendar/calendar
Syncing madduck_calendar/calendar
error: madduck_calendar/calendar: Storage "madduck_calendar_local/calendar" contains multiple items with the same UID or even content. Vdirsyncer will now abort the synchronization of this collection, because the fix for this is not clear; It could be the result of a badly behaving server. You can try running:
error:
error: vdirsyncer repair madduck_calendar_local/calendar
error:
error: But make sure to have a backup of your data in some form. The offending hrefs are:
error:
error: 'dbd3f82f544940b3b9e3d95207107ddc.ics'
error: '022f76df4eac433a88f572c1b96731d2.ics'
error: 1 out of 2 tasks failed.