Fix org-caldav: @ encoding in UIDs + nil-field event guard
Two patches in org-caldav use-package! config: Fix #1: org-caldav-get-event encodes @ as %40 via url-hexify-string. Baikal stores files with literal @ in filename (e.g. ...@google.com.ics). Result: HTTP 404 after 5 retries for UIDs with @google.com suffix. Advice: cl-letf temporarily replaces url-hexify-string to decode %40 back to @. Fix #2: Some CalDAV events have nil SUMMARY/DTSTART. icalendar parser returns nil, org-caldav passes to string-match -> Wrong type argument: stringp nil. Advice: condition-case in org-caldav-update-events-in-org catches the error, logs it to *org-caldav-debug* buffer, and allows sync state to be saved.
This commit is contained in:
23
config.el
23
config.el
@@ -1775,6 +1775,29 @@ current frame."
|
||||
(setq org-caldav-delete-org-entries 'never)
|
||||
(setq org-caldav-delete-calendar-entries 'never)
|
||||
|
||||
;; Fix #1: Baikal stores .ics files with literal @ in filename.
|
||||
;; org-caldav-get-event uses url-hexify-string which encodes @ as %40 → HTTP 404.
|
||||
;; UIDs like ...@google.com are stored on disk as literal @, so we must not encode it.
|
||||
(defadvice org-caldav-get-event (around fix-at-encoding-in-uid
|
||||
(uid &optional with-headers) activate)
|
||||
"Preserve @ in UID path for Baikal CalDAV compatibility."
|
||||
(cl-letf* ((orig-hexify (symbol-function 'url-hexify-string))
|
||||
((symbol-function 'url-hexify-string)
|
||||
(lambda (str)
|
||||
(replace-regexp-in-string "%40" "@" (funcall orig-hexify str)))))
|
||||
ad-do-it))
|
||||
|
||||
;; Fix #2: Some CalDAV events have nil SUMMARY or missing fields, causing
|
||||
;; Wrong type argument: stringp, nil inside org-caldav-update-events-in-org.
|
||||
;; This advice catches the error and logs it so sync continues to save state.
|
||||
(defadvice org-caldav-update-events-in-org (around skip-nil-field-events activate)
|
||||
"Catch nil-field errors from malformed events; log and continue."
|
||||
(condition-case err
|
||||
ad-do-it
|
||||
(wrong-type-argument
|
||||
(message "org-caldav: skipped event with nil field: %S" err)
|
||||
(org-caldav-debug-print 1 (format "Skipped nil-field event: %S" err)))))
|
||||
|
||||
(defun my/org-caldav-sync ()
|
||||
"Sync 3 CalDAV kalendářů:
|
||||
1. Osobni-Suky (default): stahuj vše → caldav-suky.org, nahraj jen calendar_outbox.org
|
||||
|
||||
Reference in New Issue
Block a user