fix: stable event hashing, HEAD fallback, caldav str/bytes compat

This commit is contained in:
2026-06-11 23:06:47 +02:00
parent 0f390ff1e1
commit d628f03a82
3 changed files with 52 additions and 9 deletions
+10 -3
View File
@@ -5,8 +5,11 @@ from typing import Any
logger = logging.getLogger(__name__)
def _extract_uid(ical_data: bytes) -> str:
for line in ical_data.decode("utf-8", errors="replace").split("\r\n"):
def _extract_uid(ical_data) -> str:
raw = ical_data
if isinstance(raw, bytes):
raw = raw.decode("utf-8", errors="replace")
for line in str(raw).split("\r\n"):
if line.upper().startswith("UID:"):
return line[4:].strip()
return ""
@@ -15,7 +18,11 @@ def _extract_uid(ical_data: bytes) -> str:
def _find_event_by_uid(calendar: Any, uid: str) -> Any | None:
try:
for event in calendar.events():
content = event.data.decode("utf-8", errors="replace")
raw = event.data
if isinstance(raw, bytes):
content = raw.decode("utf-8", errors="replace")
else:
content = str(raw)
for line in content.split("\r\n"):
if line.upper().startswith("UID:"):
if line[4:].strip() == uid: