Skip to content

Commit 0b8a3aa

Browse files
author
Chris Coutinho
committed
Prepare calendar before running tests
1 parent ed270bb commit 0b8a3aa

File tree

3 files changed

+57
-6
lines changed

3 files changed

+57
-6
lines changed

.github/workflows/test.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,19 @@ jobs:
8989
attempt=$((attempt + 1))
9090
if [ $attempt -ge $max_attempts ]; then
9191
echo "Calendar app not ready after $max_attempts attempts."
92+
# Debug output
93+
echo "Final calendar check response:"
94+
curl -u admin:admin -v -X PROPFIND http://localhost:8080/remote.php/dav/calendars/admin
9295
exit 1
9396
fi
94-
echo "Calendar app attempt $attempt/$max_attempts: Not ready, sleeping for 3 seconds..."
95-
sleep 3
97+
echo "Calendar app attempt $attempt/$max_attempts: Not ready, sleeping for 5 seconds..."
98+
sleep 5
9699
done
97100
echo "Calendar app is ready."
101+
102+
# Additional verification - wait longer for CalDAV to be fully ready
103+
echo "Waiting additional 10 seconds for CalDAV service to stabilize..."
104+
sleep 10
98105
99106
echo "All required apps are installed and ready!"
100107
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,33 @@
11
#!/bin/bash
22

3+
set -e # Exit on any error
4+
5+
echo "Installing and configuring Calendar app..."
6+
7+
# Enable calendar app
38
php /var/www/html/occ app:enable calendar
9+
10+
# Wait for calendar app to be fully initialized
11+
echo "Waiting for calendar app to initialize..."
12+
sleep 10
13+
14+
# Ensure maintenance mode is off before calendar operations
15+
php /var/www/html/occ maintenance:mode --off
16+
17+
# Create a default calendar for the admin user (may already exist, ignore errors)
18+
echo "Creating default calendar..."
19+
php /var/www/html/occ dav:create-calendar admin personal "Personal" "Default personal calendar" || true
20+
21+
# Sync DAV system to ensure proper initialization
22+
echo "Syncing DAV system..."
23+
php /var/www/html/occ dav:sync-system-addressbook
24+
25+
# Repair calendar app to ensure proper setup
26+
echo "Repairing calendar app..."
27+
php /var/www/html/occ maintenance:repair --include-expensive
28+
29+
# Final wait to ensure CalDAV service is fully ready
30+
echo "Final CalDAV initialization wait..."
31+
sleep 10
32+
33+
echo "Calendar app installation complete!"

nextcloud_mcp_server/client/calendar.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""CalDAV client for NextCloud calendar operations."""
22

3+
import asyncio
34
import xml.etree.ElementTree as ET
45
import datetime as dt
56
from typing import Dict, Any, List, Optional, Tuple
@@ -45,10 +46,23 @@ async def list_calendars(self) -> List[Dict[str, Any]]:
4546
"Accept": "application/xml",
4647
}
4748

48-
response = await self._client.request(
49-
"PROPFIND", caldav_path, content=propfind_body, headers=headers
50-
)
51-
response.raise_for_status()
49+
# Retry logic for CalDAV initialization issues
50+
max_retries = 3
51+
for attempt in range(max_retries):
52+
try:
53+
response = await self._client.request(
54+
"PROPFIND", caldav_path, content=propfind_body, headers=headers
55+
)
56+
response.raise_for_status()
57+
break
58+
except HTTPStatusError as e:
59+
if e.response.status_code == 401 and attempt < max_retries - 1:
60+
logger.warning(
61+
f"CalDAV auth failed (attempt {attempt + 1}/{max_retries}), retrying in 2s..."
62+
)
63+
await asyncio.sleep(2)
64+
continue
65+
raise
5266

5367
# Parse XML response
5468
root = ET.fromstring(response.content)

0 commit comments

Comments
 (0)