[icalendar] Use cache folder to store calendar file (#9911)

Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
This commit is contained in:
Christoph Weitkamp 2021-01-24 21:07:43 +01:00 committed by GitHub
parent 4fba096057
commit 5fe2f9c83a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -85,8 +85,14 @@ public class ICalendarHandler extends BaseBridgeHandler implements CalendarUpdat
TimeZoneProvider tzProvider) { TimeZoneProvider tzProvider) {
super(bridge); super(bridge);
this.httpClient = httpClient; this.httpClient = httpClient;
calendarFile = new File(OpenHAB.getUserDataFolder() + File.separator final File cacheFolder = new File(new File(OpenHAB.getUserDataFolder(), "cache"),
+ getThing().getUID().getAsString().replaceAll("[<>:\"/\\\\|?*]", "_") + ".ical"); "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; eventPublisherCallback = eventPublisher;
updateStatesLastCalledTime = Instant.now(); updateStatesLastCalledTime = Instant.now();
this.tzProvider = tzProvider; this.tzProvider = tzProvider;