Hanse00 / LecToCal

Synchronising Lectio schedules into Google Calendar.
Apache License 2.0
5 stars 6 forks source link

Update old entries instead of failing #4

Closed Sobuno closed 8 years ago

Sobuno commented 8 years ago

I encountered a situation where I was getting 409 (Conflict) back from Google's API when adding a lesson. When investigating, I found that the problem happened if the lesson ID had already been used in the past as an identifier for the entry in the Google Calendar.

Example of timeline that would cause the bug: I run the script to import entries. Lesson A is imported and scheduled on Date A. Lesson A is moved to Date B, B>A I run the script again at a later time than Date A, making the check to see if the lesson already exists in Google Calendar fail, thus giving a 409 (Conflict) when trying to add it.

Hanse00 commented 8 years ago

I noticed this problem before myself.

It's caused by the fact that deleting an entry through the Google Calendar API isn't a "hard" delete, it actually just removes the entry from the calendar, but the entry still exists. Trying to create another entry with the same ID afterwards, will therefore cause issues.

However due to the way the update mechanism works, I am basically deleting an event, and creating it again elsewhere, with the same ID. (If I remember correctly)

I will gladly merge this change, however I would also propose you get write access to the repository. As my current employment prohibits me from writing open source code without going through a lengthy legal process, and you are the primary contributor anyway at this time, I would like to remove myself from getting in your way of improving the project.

What do you think?

Sobuno commented 8 years ago

Yeah, sure. I do not use Lectio directly myself - the changes/fixes I make are based on my girlfriend's requests. She is a teacher, so I will likely find myself running this script for many years to come.