diff options
Diffstat (limited to '')
-rw-r--r-- | module/output/vdir.scm | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/module/output/vdir.scm b/module/output/vdir.scm index cf4f6c8d..bd21fb24 100644 --- a/module/output/vdir.scm +++ b/module/output/vdir.scm @@ -2,6 +2,11 @@ ;;; Module for writing components to the vdir storage format. ;;; Currently also has some cases for "big" icalendar files, ;;; but those are currently unsupported. + +;;; TODO generalize save-event and remove-event into a general interface, +;;; which different database backends can implement. Actually, do that for all +;;; loading and writing. + ;;; Code: (define-module (output vdir) @@ -22,12 +27,29 @@ [(vdir) (let* ((uid (or (prop event 'UID) (uuidgen)))) - (set! (prop event 'UID) uid) - (with-atomic-output-to-file - (string-append (prop calendar '-X-HNH-DIRECTORY) / uid ".ics") + (set! (prop event 'UID) uid + ;; TODO use existing filename if present? + (prop event '-X-HNH-FILENAME) (string-append + (prop calendar '-X-HNH-DIRECTORY) + / uid ".ics")) + (with-atomic-output-to-file (prop event '-X-HNH-FILENAME) (lambda () (print-components-with-fake-parent (list event)))) uid)] [else (error "Source of calendar unknown, aborting.") ])) + + +(define-public (remove-event event) + (define calendar (parent event)) + (case (prop calendar '-X-HNH-SOURCETYPE) + [(file) + (error "Removing events from large files unsupported")] + + [(vdir) + (delete-file (prop event '-X-HNH-FILENAME))] + + [else + (error "Source of calendar unknown, aborting.") + ])) |