From e9503bb08f83896baeb4b78a2c9c1e9a9effa2f5 Mon Sep 17 00:00:00 2001 From: storm64 Date: Wed, 17 Aug 2022 23:21:35 +0200 Subject: [PATCH] sleeplog: Update boot.js Check for cached modules before removing to prevent module not found error. --- apps/sleeplog/boot.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/sleeplog/boot.js b/apps/sleeplog/boot.js index e2b7f45d9..c1f8a2d2d 100644 --- a/apps/sleeplog/boot.js +++ b/apps/sleeplog/boot.js @@ -290,8 +290,8 @@ if (sleeplog.conf.enabled) { // update stats cache if available if (this.statsCache) this.statsCache = require("sleeplog").getStats(); } - // remove module from cache if not on debugging - if (!this.debug) Modules.removeCached("sleeplog"); + // remove module from cache if cached + if (Modules.getCached().includes("sleeplog")) Modules.removeCached("sleeplog"); } }, @@ -314,7 +314,8 @@ if (sleeplog.conf.enabled) { if (this.statsCache === undefined || this.statsCache.calculatedAt + 432E5 < Date.now()) { // read stats of the last night into cache and remove module from cache this.statsCache = require("sleeplog").getStats(); - Modules.removeCached("sleeplog"); + // remove module from cache if cached + if (Modules.getCached().includes("sleeplog")) Modules.removeCached("sleeplog"); } // return stats cache return this.statsCache;