Skip to content

Commit f40007c

Browse files
committed
vdir: various clarifications and rewording
1 parent de58811 commit f40007c

1 file changed

Lines changed: 102 additions & 50 deletions

File tree

content/specs/vdir.md

Lines changed: 102 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -5,103 +5,155 @@ date: 2025-03-31
55
categories: specs
66
---
77

8-
This document describes a standard for storing calendars and contacts on a
9-
filesystem, with the main goal of being easy to implement.
10-
11-
Vdirsyncer synchronizes to vdirs via [`filesystem`]. Each vdir (basically just
12-
a directory with some files in it) represents a calendar or address book.
13-
14-
[`filesystem`]: https://vdirsyncer.pimutils.org/en/stable/config.html#storage-filesystem
8+
This specification describes a convention for storing calendars and address
9+
books in a filesystem, with the main goal of being ease of implementation, and
10+
compatibility with existing standards.
1511

1612
# Basic Structure
1713

18-
The main folder (root) contains an arbitrary number of subfolders
19-
(collections), which contain only files (items). Synonyms for "collection" may
20-
be "address book" or "calendar".
14+
A main (root) directory contains an arbitrary number of subdirectories. Each
15+
subdirectory is a collection (an address book or a calendar). Each of these
16+
collections contains items, which may be contacts or calendar components
17+
(events, todos and/or journal entries) respectively.
18+
19+
An item may only be one of the following two types:
2120

22-
An item is:
21+
- A [vCard] file, in which case the file extension MUST be `.vcf`.
22+
- An [iCalendar] file, in which case the file extension MUST be `.ics`.
2323

24-
- A [vCard] file, in which case the file extension *must* be `.vcf`, *or*
25-
- An [iCalendar] file, in which case the file extension *must* be `.ics`.
24+
[vCard]: https://tools.ietf.org/html/rfc6350
25+
[iCalendar]: https://tools.ietf.org/html/rfc5545
2626

27-
An item *should* contain a `UID` property as described by the vCard and
28-
iCalendar standards. If it contains more than one `UID` property, the values
29-
of those *must* not differ.
27+
An item SHOULD contain a `UID` property as described by the vCard and iCalendar
28+
specifications. If it contains more than one `UID` property, the values of
29+
those MUST NOT differ.
3030

31-
The file *must* contain exactly one event, task or contact. In most cases this
31+
The file MUST contain exactly one event, task or contact. In most cases this
3232
also implies only one `VEVENT`/`VTODO`/`VCARD` component per file, but
33-
e.g. recurrence exceptions would require multiple `VEVENT` components per
34-
event.
33+
e.g. recurrence exceptions require multiple `VEVENT` components per event.
34+
35+
## Filenames
3536

3637
The filename should have similar properties as the `UID` of the file content.
3738
However, there is no requirement for these two to be the same. Programs may
3839
choose to store additional metadata in that filename, however, at the same time
39-
they *must not* assume that the metadata they included will be preserved by
40-
other programs.
40+
they MUST NOT assume that the metadata they included will be preserved by other
41+
programs.
4142

42-
[vCard]: https://tools.ietf.org/html/rfc6350
43-
[iCalendar]: https://tools.ietf.org/html/rfc5545
43+
Filenames SHOULD be URL-safe, such that can be retained when synchronising to
44+
WebDAV collections.
4445

4546
# Metadata
4647

47-
Any of the below metadata files may be absent. None of the files listed below
48-
have any file extensions.
48+
Any following metadata files may optionally be present. None of the files
49+
listed below have any file extensions.
4950

50-
- A file called `color` inside the vdir indicates the vdir's color, a
51+
- A file called `color` inside the vdir indicates that collection's color, a
5152
property that is only relevant in UI design.
5253

5354
Its content is an ASCII-encoded hex-RGB value of the form `#RRGGBB`. For
5455
example, a file content of `#FF0000` indicates that the vdir has a red
5556
(user-visible) color. No short forms or informal values such as `red` (as
56-
known from CSS, for example) are allowed. The prefixing `#` must be
57+
known from CSS, for example) are allowed. The prefixing `#` MUST be
5758
present.
5859

59-
- Files called `displayname` and `description` contain a UTF-8 encoded label/
60-
description, that may be used to represent the vdir in UIs.
60+
- A file called `displayname` contain a UTF-8 encoded label description that
61+
is suitable for presentation to the user. This property is a counterpart to
62+
the `DAV:displayname` WebDAV property defined in [rfc4918 section 15.2].
63+
64+
[rfc4918 section 15.2]: https://www.rfc-editor.org/rfc/rfc4918#section-15.2
65+
66+
- A `description` contain a UTF-8 encoded description, which provides a
67+
human-readable description of a calendar or an address book. This property is
68+
a counterpart to the [`CALDAV:calendar-description`][ccd] and
69+
[`CARDDAV:addressbook-description`][cad] properties in CalDAV and CardDAV
70+
respectively.
71+
72+
[ccd]: https://www.rfc-editor.org/rfc/rfc4791#section-5.2.1
73+
[cad]: https://www.rfc-editor.org/rfc/rfc6352#section-6.2.1
74+
75+
- A file called `order` inside the vdir includes the relative order of a
76+
collection. This property is only use for presentational purposes. Its value
77+
shall be a numeric string, and collections shall be sorted relative to this
78+
value.
6179

62-
- A file called `order` inside the vdir includes the relative order
63-
of the calendar, a property that is only relevant in UI design.
80+
These properties and their names were chosen to match existing CalDAV and
81+
CardDAV properties, given that a `vdir` is commonly synchronised using one of
82+
these two protocols.
83+
84+
Property files with an invalid content SHOULD be ignored. Application software
85+
SHOULD warn the user of the invalidity when appropriate.
6486

6587
# Writing to vdirs
6688

67-
Creating and modifying items or metadata files *should* happen [atomically].
89+
Creating and modifying items or metadata files MUST happen [atomically]. That
90+
is, a file matching one of the extensions mentioned above must never be
91+
partially written; if it exists, it must be complete.
6892

6993
[atomically]: https://en.wikipedia.org/wiki/Atomicity_%28programming%29
7094

95+
This requirement has two purposes:
96+
97+
- Ensure that one program will never read an item which has only partially been
98+
written by another tool.
99+
- Ensure that a fatal system crash shall never result in a corrupt item.
100+
71101
Writing to a temporary file on the same physical device, and then moving it to
72-
the appropriate location is usually a very effective solution. For this
73-
purpose, files with the extension `.tmp` may be created inside collections.
102+
the appropriate location is usually an effective solution. For this purpose,
103+
files with the extension `.tmp` may be created inside collections.
74104

75-
When changing an item, the original filename *must* be used.
105+
When changing an item, the original filename MUST be used.
76106

77107
# Reading from vdirs
78108

79-
- Any file ending with the `.tmp` or no file extension *must not* be treated
80-
as an item.
109+
- Any file ending with the `.tmp` or no file extension MUST NOT be treated as
110+
an item.
81111

82-
- The `ident` part of the filename *should not* be parsed to improve the
83-
speed of item lookup.
112+
- The `ident` part of the filename SHOULD NOT be parsed to improve the speed
113+
of item lookup.
84114

85115
# Considerations
86116

87117
The primary reason this format was chosen is due to its compatibility with the
88118
[CardDAV] and [CalDAV] standards.
89119

90-
[CardDAV]: http://tools.ietf.org/html/rfc6352
91-
[CalDAV]: http://tools.ietf.org/search/rfc4791
120+
[CardDav]: https://www.rfc-editor.org/rfc/rfc6352
121+
[CalDAV]: https://www.rfc-editor.org/rfc/rfc4791
92122

93123
## Performance
94124

95-
Currently, vdirs suffer from a rather major performance problem, one which
125+
Currently, a vdir suffer from a rather major performance problem, one which
96126
current implementations try to mitigate by building up indices of the
97127
collections for faster search and lookup.
98128

99-
The reason items' filenames don't contain any extra information is simple: The
100-
solutions presented induced duplication of data, where one duplicate might
101-
become out of date because of bad implementations. As it stands right now, an
102-
index format could be formalized separately though.
129+
Item filenames convey not additional information within the scope of this
130+
specification. Any attempt to encode information in these results in
131+
duplication of data, where one duplicate might become out of date because of
132+
bad implementations. As it stands right now, an index format could be
133+
formalized separately though.
134+
135+
Synchronisation tools such as [vdirsyncer] or [pimsync] don't really have to
136+
bother about efficient item lookup, because its synchronization algorithm needs
137+
to fetch the whole list of items anyway. Detecting changes is easily
138+
implemented by checking the files' modification time.
139+
140+
[vdirsyncer]: https://vdirsyncer.pimutils.org/en/stable/
141+
[pimsync]: https://pimsync.whynothugo.nl/
142+
143+
# History
144+
145+
## Version 1.0.0
146+
147+
The original version of this was published as part of [the vdirsyncer
148+
documentation]. However, the conventions described in this document are
149+
intended to be adopted by other command line and desktop tools operating on
150+
calendar and address book collections.
151+
152+
[the vdirsyncer documentation]: https://vdirsyncer.pimutils.org/en/stable/vdir.html
153+
154+
## Version 1.1.0 (2025-03-31)
155+
156+
Published this specification separately, including several clarifications and
157+
minor rewording.
103158

104-
vdirsyncer doesn't really have to bother about efficient item lookup, because
105-
its synchronization algorithm needs to fetch the whole list of items anyway.
106-
Detecting changes is easily implemented by checking the files' modification
107-
time.
159+
Added a recommendation for item filenames to be URL-safe.

0 commit comments

Comments
 (0)