sleeplog: Update boot.js

Check for cached modules before removing to prevent module not found error.
pull/2110/head
storm64 2022-08-17 23:21:35 +02:00 committed by GitHub
parent 33c8aa3143
commit e9503bb08f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 3 deletions

View File

@ -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;