pimutils / khal

:calendar: CLI calendar application
https://lostpackets.de/khal/
MIT License
2.62k stars 207 forks source link

Incorrectly identifies/configures vdirsyncer calendars #586

Open madduck opened 7 years ago

madduck commented 7 years ago

This might be related to #145, but that issue seems stale and done, so here's a new one, from https://bugs.debian.org/855654:

I just set up khal and let it discover my vdirsyncer config:

The following collections were found: madduck_calendar_local: ~/.var/vdirsyncer/calendar madduck_contacts_local: ~/.var/vdirsyncer/contacts

First, the second of those is a contact store, and khal really should just ignore it, rather than create a stanza for it under [calendars]:

[calendars]
[[madduck_calendar_local]]
path = ~/.var/vdirsyncer/calendar
type = calendar
[[madduck_contacts_local]]
path = ~/.var/vdirsyncer/contacts
type = discover

Second, this is actually wrong, because the above is the filesystem root for the collections that belong to the sync pair, but khal identifies that as a collection itself. The actual sync pair is called "calendar.ics".

This has the following effect: khal parses the directory and descends into ~/.var/vdirsyncer/calendar/calendar.ics/, but also into all other collections under ~/.var/vdirsyncer/calendar/.

Furthermore, new events are generated directly in ~/.var/vdirsyncer/calendar/ and thus will not be picked up by vdirsyncer's next sync run.

The right thing to do would be to create a calendar for every collection within the vdirsyncer filesystem locations. And in fact, if I manually change the path to ~/.var/vdirsyncer/calendar/calendar.ics/ in the khal config, then it works.

geier commented 7 years ago

Hi and thank you for reporting this, can you please share the relevant part of your vdirsyncer configuration?

madduck commented 7 years ago

Sure, @geier:

[pair madduck_contacts]
a = "madduck_contacts_local"
b = "madduck_contacts_remote"
collections = ["from b"]
conflict_resolution = "b wins"
metadata = ["displayname"]

[storage madduck_contacts_local]
type = "filesystem"
path = "~/.var/vdirsyncer/contacts"
fileext = ".vcf"

[storage madduck_contacts_remote]
type = "carddav"
url = "https://carddav.madduck.net/…"
username = "…"
password = "…"
madduck commented 7 years ago

Here's a relevant bit from vdirsyncer(1):

If we set collections = null, ./contacts_foo/ and ./contacts_bar/ are no longer treated as folders with collections, but as collections themselves. This means that ./contacts_foo/ and ./contacts_bar/ will contain .vcf-files, not subfolders that contain .vcf-files.

In other words, the way khal works seems to assume collections = null, so when parsing the config, you have to account for that.

untitaker commented 7 years ago

vdirsyncer should probably offer a command-line API for discovering all calendars at some point.