dengste / org-caldav

Caldav sync for Emacs orgmode
GNU General Public License v3.0
718 stars 105 forks source link

Fresh sync can't find its own ID(s) #230

Closed jypma closed 1 year ago

jypma commented 3 years ago

I've just done a fresh sync to my NextCloud calendar (~700 entries). Everything came over with no errors, and events have arrived in the "inbox" file, with state written to the "save" file.

However, if I now sync again, the sync always fails with an error message related to the ID of the first event in the inbox file:

org-caldav-generate-md5-for-org-entry: Could not find UID 2016-07-18T19_00_22+0200-29586-1000-1-00000000_jinkpad-20160718T170057Z.

That is literally the ID of the first event in the file.

If I then sync again and select "resume", org-caldav says the sync succeeded, but I'm not sure if everything was updated.

It looks like org-caldav-generate-md5-for-org-entry uses org-id to lookup an org file for an event's UUID; I haven't configured org-id at all, should I?

My current config looks like this

(use-package org-caldav
  :commands (org-caldav-sync)
  :init
  (setq org-caldav-url "https://XXX/remote.php/dav/calendars/jan")
  (setq org-caldav-calendars
        '((:calendar-id "default"
                        :files ("~/.cache/org-caldav/calendars/default.org")
                        :inbox "~/.cache/org-caldav/calendars/default-inbox.org")))
  (setq org-caldav-backup-file "~/.cache/org-caldav/org-caldav-backup.org")
  (setq org-caldav-save-directory "~/.cache/org-caldav/save/")
  :config
  (setq org-icalendar-alarm-time 1)
  (setq org-icalendar-include-todo t)
  (setq org-icalendar-use-deadline '(event-if-todo event-if-not-todo todo-due))
  (setq org-icalendar-use-scheduled '(todo-start event-if-todo event-if-not-todo)))
morkr commented 3 years ago

Hello,

I just installed and have a similar/same problem. Two events in testcalendar on my Nextcloud. First sync works fine and events show up in inbox file. Then anytime I try to resync, an error is reported:

2 files scanned, 0 files contains IDs, and 0 IDs found. org-caldav-generate-md5-for-org-entry: Could not find UID 24B640BC-85E6-4321-B0F4-0C8444C42EF2.

When I try to sync another time, after the error, and select resume, it tells me to have succeeded, but a new event I created is not pulled in from the Nextcloud.

Also, on leaving emacs, I am prompted if the unsaved buffers /tmp/org-caldav-pI92Zo and such should be killed or not. From the org-caldav-debug buffer I gather that those are ics files generated during the errored sync. Like so: ========== Started sync. Check connection for https://server.domain.org/remote.php/dav/calendars/USER/CALENDARNAME/. Generating ICS file /tmp/org-caldav-vUvK04. === Updating EventDB from Org /tmp/org-caldav-pI92Zo. === Updating EventDB from Org

Is that the desired function?

The error is reproducible after having deleted the database file and the entries in the inbox file manually.

I am using Doom Emacs version 2.0.9

I would be glad if anyone could help

Have a great day!

fleimgruber commented 3 years ago

@dengste could you give us a hint on how to debug this?

zeroset commented 3 years ago

Hi, i have the exact same error. Especially the ics file downloaded from Nextcloud has a different UID as name then it is written as UID in the file itself. Any solution here?

odi commented 3 years ago

I had the same problem. I am not sure how org-id-find (from org-id) works in detail but apparently the file has to be in the org-agenda-files. I guess only org-agenda-files will be stored in the org-id-locations where org-id searches for the filename of a given ID. If it's not there org-id and org-caldav will not be able to resolve this IDs. But I am not sure.

Maybe this helps a bit.

sylph1o commented 3 years ago

Thanks @odi ! I have the same problem and cannot try your fix right now. Did it solve the problem for you?

odi commented 3 years ago

Thanks @odi ! I have the same problem and cannot try your fix right now. Did it solve the problem for you?

Yes it does. In my case it was simple, the file was not in den org-agenda-files and after I added it with e.g. C-c [ or org-agenda-file-to-front it works without any problems.

Because maybe org-id is searching only in the agenda-files? I am not sure.

fleimgruber commented 3 years ago

@odi thanks for sharing this! Adding the calendar file to org-agenda-files solves this for me as well.

artelse commented 2 years ago

Am having the same problem and adding the caldav files to the org-agenda-files doesn't resolve the issue. It is weird that the inbox and files org files remain empty after a sync, although the sync file shows the events. EDIT: What fixed the ID not found error is adding the agenda files to org-id-extra-files. Now my calendar remains empty still, but am getting closer.

jackkamm commented 1 year ago

I believe that the ID-related bugs should be fixed now that I've merged https://github.com/dengste/org-caldav/pull/252, but please let us know if you continue to experience these issues.

tenpast commented 1 year ago

Hi! First, thank you for the great package.

I just installed org-caldav today and experienced the same behavior described. First sync (Org > Nextcloud) worked perfectly. Next syncs did not work, with the same "Unable to find UID" error.

The error was caused by the calendar org file not being added to org-id-files after the first sync (after creating Org ID's for each entry).

Manual solution:

I created a new heading on the Org calendar file and used the org-id-get-create command to manually create an ID. This action added the calendar file to org-id-files.

I deleted the entry with the manually created ID. Syncing seems to work without an issue now.

Relevant software:

Archlinux Emacs 28.2 Org Mode 9.5.5 org-caldav 20230421.1620

Package configuration:


(use-package org-caldav
  :config
  (setq org-caldav-url "https://url.com/...")
  (setq org-caldav-calendar-id "calendar-id")
  (setq org-caldav-inbox "~/calendar.org")
  (setq org-caldav-files '( "~/calendar.org"))
  (setq org-icalendar-timezone "My/Timezone")
  (setq org-icalendar-alarm-time 30)
  (setq org-caldav-delete-org-entries "always")
  (setq org-caldav-delete-calendar-entries "always"))