From 5fe2f9c83a34c050ad17511466196f8c25e33d05 Mon Sep 17 00:00:00 2001 From: Christoph Weitkamp Date: Sun, 24 Jan 2021 21:07:43 +0100 Subject: [PATCH] [icalendar] Use cache folder to store calendar file (#9911) Signed-off-by: Christoph Weitkamp --- .../icalendar/internal/handler/ICalendarHandler.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/bundles/org.openhab.binding.icalendar/src/main/java/org/openhab/binding/icalendar/internal/handler/ICalendarHandler.java b/bundles/org.openhab.binding.icalendar/src/main/java/org/openhab/binding/icalendar/internal/handler/ICalendarHandler.java index 916017b0e30..632a818f3a5 100644 --- a/bundles/org.openhab.binding.icalendar/src/main/java/org/openhab/binding/icalendar/internal/handler/ICalendarHandler.java +++ b/bundles/org.openhab.binding.icalendar/src/main/java/org/openhab/binding/icalendar/internal/handler/ICalendarHandler.java @@ -85,8 +85,14 @@ public class ICalendarHandler extends BaseBridgeHandler implements CalendarUpdat TimeZoneProvider tzProvider) { super(bridge); this.httpClient = httpClient; - calendarFile = new File(OpenHAB.getUserDataFolder() + File.separator - + getThing().getUID().getAsString().replaceAll("[<>:\"/\\\\|?*]", "_") + ".ical"); + final File cacheFolder = new File(new File(OpenHAB.getUserDataFolder(), "cache"), + "org.openhab.binding.icalendar"); + if (!cacheFolder.exists()) { + logger.debug("Creating cache folder '{}'", cacheFolder.getAbsolutePath()); + cacheFolder.mkdirs(); + } + calendarFile = new File(cacheFolder, + getThing().getUID().getAsString().replaceAll("[<>:\"/\\\\|?*]", "_") + ".ical"); eventPublisherCallback = eventPublisher; updateStatesLastCalledTime = Instant.now(); this.tzProvider = tzProvider;