From 4ffab9225cd618c2c9d2e95c06ef7b71c2dd5b11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Thu, 13 Aug 2020 10:36:47 +0200 Subject: Changing calendar now unlinks old file. --- module/output/vdir.scm | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'module/output/vdir.scm') diff --git a/module/output/vdir.scm b/module/output/vdir.scm index cf4f6c8d..f23e0062 100644 --- a/module/output/vdir.scm +++ b/module/output/vdir.scm @@ -22,12 +22,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.") + ])) -- cgit v1.2.3