derekantrican / GAS-ICS-Sync

A Google Apps Script for syncing ICS/ICAL files faster than the current Google Calendar speed
GNU General Public License v3.0
1.55k stars 197 forks source link

iCal Provider rejects request resulting in deletion of all calendar events #312

Closed babyarms closed 1 year ago

babyarms commented 1 year ago

It's not stated by the provider, but if they receive too many requests, they deny us from pulling from the iCal. The times are inconsistent, they can work within 5-minute sync times, or 1 hour sync times can cause an issue result in HTTP error 429. Is there a way to adjust the code to do a try/catch or completely quit upon URL response equaling to 429 to prevent deletion?

Currently, if we receive the HTTP 429 error, all events existing in the calendar are deleted. The next time it syncs, it creates new events, but becomes an endless loop. I was going through some other issues and someone else had a similar problem but didn't seem to be a solution. I'm only using one calendar and one iCal if that is relevant.

jonas0b1011001 commented 1 year ago

You can stop the execution and prevent removal of the events by adding

if (responses.length == 0)
      return;

above code.gs L160

derekantrican commented 1 year ago

@babyarms - did you try out @jonas0b1011001 's suggestion?

derekantrican commented 1 year ago

Closing as there has been no response. Please comment again if this is still an issue