Fix org-caldav: ignore 775 @google.com UIDs + broad error handler
Reverted Fix #1 (@ URL encoding) - caused URL parser issues and was unnecessary. Fix #2 (updated): 775 events have @google.com UIDs. Emacs URL parser misinterprets literal @ in path as userinfo separator, connecting to wrong host -> 5 retries all fail -> crash. Solution: before-advice on org-caldav-update-events-in-org marks all @google.com UIDs as 'ignored' before the retrieval loop starts. Org-caldav natively skips 'ignored' events. Logged to *org-caldav-debug*. Fix #2 around-advice: catch any remaining errors in update-events-in-org so sync state is saved even if individual events fail. Fix #3 (unchanged): set-sequence-number fallback for PUT failures.
This commit is contained in:
40
config.el
40
config.el
@@ -1775,28 +1775,30 @@ current frame."
|
|||||||
(setq org-caldav-delete-org-entries 'never)
|
(setq org-caldav-delete-org-entries 'never)
|
||||||
(setq org-caldav-delete-calendar-entries 'never)
|
(setq org-caldav-delete-calendar-entries 'never)
|
||||||
|
|
||||||
;; Fix #1: Baikal stores .ics files with literal @ in filename.
|
;; Fix #2: Events with @google.com UIDs fail retrieval (Emacs URL parser
|
||||||
;; org-caldav-get-event uses url-hexify-string which encodes @ as %40 → HTTP 404.
|
;; misinterprets @ in path as userinfo separator, connecting to wrong host).
|
||||||
;; UIDs like ...@google.com are stored on disk as literal @, so we must not encode it.
|
;; There are 775 such events. Mark them as 'ignored' before update-events-in-org
|
||||||
(defadvice org-caldav-get-event (around fix-at-encoding-in-uid
|
;; processes them. Org-caldav natively skips 'ignored' events.
|
||||||
(uid &optional with-headers) activate)
|
;; Also catch any remaining nil-field or retrieval errors to keep sync alive.
|
||||||
"Preserve @ in UID path for Baikal CalDAV compatibility."
|
(defadvice org-caldav-update-events-in-org (before ignore-google-uids activate)
|
||||||
(cl-letf* ((orig-hexify (symbol-function 'url-hexify-string))
|
"Mark @google.com UIDs as ignored to prevent URL parsing failures."
|
||||||
((symbol-function 'url-hexify-string)
|
(let ((count 0))
|
||||||
(lambda (str &optional allowed-chars)
|
(dolist (event org-caldav-event-list)
|
||||||
(replace-regexp-in-string "%40" "@" (funcall orig-hexify str allowed-chars)))))
|
(when (and (stringp (car event))
|
||||||
ad-do-it))
|
(string-match "@google\\.com$" (car event)))
|
||||||
|
(org-caldav-event-set-status event 'ignored)
|
||||||
|
(setq count (1+ count))))
|
||||||
|
(when (> count 0)
|
||||||
|
(message "org-caldav: marked %d @google.com UIDs as ignored" count)
|
||||||
|
(org-caldav-debug-print 1 (format "Ignored %d @google.com UIDs" count)))))
|
||||||
|
|
||||||
;; Fix #2: Some CalDAV events have nil SUMMARY or missing fields, causing
|
(defadvice org-caldav-update-events-in-org (around skip-failed-events activate)
|
||||||
;; Wrong type argument: stringp, nil inside org-caldav-update-events-in-org.
|
"Catch errors during cal->org sync; log and return so sync state is saved."
|
||||||
;; 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
|
(condition-case err
|
||||||
ad-do-it
|
ad-do-it
|
||||||
(wrong-type-argument
|
(error
|
||||||
(message "org-caldav: skipped event with nil field: %S" err)
|
(message "org-caldav: update-events-in-org stopped early: %S" err)
|
||||||
(org-caldav-debug-print 1 (format "Skipped nil-field event: %S" err)))))
|
(org-caldav-debug-print 1 (format "update-events-in-org error: %S" err)))))
|
||||||
|
|
||||||
;; Fix #3: org-caldav-set-sequence-number calls org-caldav-get-event to read
|
;; Fix #3: org-caldav-set-sequence-number calls org-caldav-get-event to read
|
||||||
;; the current SEQUENCE from server before pushing updates. If the GET fails
|
;; the current SEQUENCE from server before pushing updates. If the GET fails
|
||||||
|
|||||||
Reference in New Issue
Block a user