fix: auto-prune deleted Synology calendars during event fetch
When a Synology calendar returns 404 during event fetch, remove it from the stored calendar list instead of silently returning empty results. v1.57.4 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
87d78d78b5
commit
93e808ddfa
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "my-weekly-todo-list",
|
||||
"version": "1.57.3",
|
||||
"version": "1.57.4",
|
||||
"description": "A web-based weekly task management application that organizes to-dos and calendar events in a single, intuitive weekly view",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
||||
@ -518,10 +518,24 @@ export const getCalendarEvents = async (
|
||||
attachments: event.attachments as EventAttachment[] || undefined,
|
||||
};
|
||||
}));
|
||||
} catch (calError) {
|
||||
} catch (calError: any) {
|
||||
const msg = calError?.message || '';
|
||||
if (msg.includes('not found') || msg.includes('Not found') || calError?.status === 404) {
|
||||
console.warn(`[CALENDAR] Synology: calendar ${calendarId} not found, removing from stored list`);
|
||||
calendars = calendars.filter((c: any) => c.id !== calendarId);
|
||||
try {
|
||||
await prisma.calendarConnection.update({
|
||||
where: { id: connection.id },
|
||||
data: { calendars: calendars },
|
||||
});
|
||||
} catch (dbErr) {
|
||||
console.error('[CALENDAR] Synology: failed to prune calendar from DB:', dbErr);
|
||||
}
|
||||
} else {
|
||||
console.error(`[CALENDAR] Synology: error fetching events from calendar ${calendarId}:`, calError);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (connection.provider === 'outlook') {
|
||||
console.log('[CALENDAR] Processing Outlook connection:', connection.id);
|
||||
|
||||
|
||||
@ -372,8 +372,13 @@ export const getUpcomingEvents = async (
|
||||
} catch (error: any) {
|
||||
const msg = error?.message || '';
|
||||
const status = error?.response?.status || error?.status;
|
||||
// Silently handle expected failures (stale/deleted calendars, permission issues)
|
||||
if (status === 405 || status === 404 || msg.includes('405') || msg.includes('Not Allowed') || msg.includes('not found')) {
|
||||
// Re-throw 404 so callers can prune deleted calendars
|
||||
if (status === 404 || msg.includes('not found') || msg.includes('Calendar not found')) {
|
||||
console.warn(`[SYNOLOGY CALENDAR] Calendar not found: ${calendarUrl}`);
|
||||
throw error;
|
||||
}
|
||||
// Silently handle other expected failures (permission issues, method not allowed)
|
||||
if (status === 405 || msg.includes('405') || msg.includes('Not Allowed')) {
|
||||
console.warn(`[SYNOLOGY CALENDAR] Calendar unavailable (${status || msg.slice(0, 60)}): ${calendarUrl}`);
|
||||
} else {
|
||||
console.error(`[SYNOLOGY CALENDAR] Error fetching events for ${calendarUrl}:`, error);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user