0xStubs

Computer science, IT, Photography

Broken calendar migration from Google to ownCloud

For some time now I run a small ownCloud instance to synchronize my contacts and calendars across different devices. When another person tried to migrate his Google calendars to this instance there was an issue though. The .ics files exported from Google contained invalid entries that were copied into ownCloud’s database and broke synchronization with 3rd party applications like Thunderbird’s Lightning extension.

So, what exactly was the problem? Lightning threw a lot of the following errors:

Exception:[Exception... "Component returned failure code: 0x8000ffff 
(NS_ERROR_UNEXPECTED) [calIIcalComponent.endTime]"  nsresult: 
"0x8000ffff (NS_ERROR_UNEXPECTED)"  location: [...]

This gave a hint that the issue lies somewhere in the end time of certain calendar entries. And in fact the file contained lines like the following:

DTEND;VALUE=:20140417T150000Z

Looking at the RFC in question it becomes clear that this line is invalid and should rather look like one of the following:

DTEND;VALUE=DATE-TIME:20140417T150000Z
DTEND:20140417T150000Z

So, for a quick fix I went into the ownCloud database and repaired the broken entries using the following SQL command:

UPDATE `oc_clndr_objects` SET
 `calendardata` = REPLACE(`calendardata`, 'DTEND;VALUE=:', 'DTEND;VALUE=DATE-TIME:'),
 `lastmodified` = UNIX_TIMESTAMP(NOW())
WHERE `calendardata` LIKE '%DTEND;VALUE=:%';

To be sure all clients would pick up these changes I also increased the `ctag` in `oc_clndr_calendars` for the affected calendars.

After this the problem was solved. It is unclear though whether it is a bug in the Google calendar export or if the affected entries were created by broken clients.

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.