Skip to content

Commit

Permalink
fix reload of images after daily cache clear
Browse files Browse the repository at this point in the history
  • Loading branch information
petersem committed Sep 11, 2024
1 parent 1df24ac commit c9fe21c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
25 changes: 18 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ let contentRatings;
let oldAwtrixApps = [];
let isAwtrixEnabled = false;
let awtrixIP = "";
let restartSeconds = 86400000; //60000; //

// create working folders if they do not exist
// needed for package binaries
Expand All @@ -128,6 +129,7 @@ const { titleColour, enableSleep, sleepStart, sleepEnd, numberOnDemand } = requi
const CardType = require("./classes/cards/CardType");
const MediaCard = require("./classes/cards/MediaCard");
const Links = require("./classes/custom/links");
const { now } = require("jquery");

var dir = './config';

Expand Down Expand Up @@ -864,13 +866,9 @@ async function loadOnDemand() {
* @returns nothing
*/
async function houseKeeping() {
// stop the clock
clearInterval(houseKeepingClock);
// clean cache
await core.DeleteMP3Cache();
await core.DeleteImageCache();
// restart timer
houseKeepingClock = setInterval(houseKeeping, 86400000); // daily
}

/*
Expand Down Expand Up @@ -1071,6 +1069,9 @@ async function checkEnabled() {
sleepRange = "";
}

// calculate daily restart time
let timeObject = new Date(Date.now() + restartSeconds);

console.log(
`--- Enabled Status ---
Plex: ` +
Expand Down Expand Up @@ -1103,7 +1104,10 @@ async function checkEnabled() {
Trivia: ` +
isTriviaEnabled +
`
`
Daily restart commencing at: ` +
timeObject.toLocaleTimeString() +
`
`
);
return;
}
Expand Down Expand Up @@ -1199,7 +1203,11 @@ async function startup(clearCache) {
linkCards = [];

// run housekeeping job
if (clearCache !== false) await houseKeeping();
if (clearCache !== false){
await houseKeeping();
// let d = new Date();
// console.log(d.toLocaleString() + ` ** Restart/reload **`);
}
// TODO to remove this! console.log(clearCache);
// load settings object
loadedSettings = await Promise.resolve(await loadSettings());
Expand All @@ -1214,7 +1222,7 @@ async function startup(clearCache) {
globalPage.hideSettingsLinks = loadedSettings.hideSettingsLinks !== undefined ? loadedSettings.hideSettingsLinks : 'false';

// restart timer for houseKeeping
houseKeepingClock = setInterval(houseKeeping, 86400000); // daily
//houseKeepingClock = setInterval(houseKeeping, 86400000); // daily
}

// check status
Expand Down Expand Up @@ -1370,6 +1378,9 @@ async function startup(clearCache) {
clearInterval(sleepClock);
sleep = "false";
}
// restart timer
houseKeepingClock = setInterval(startup, restartSeconds); // daily

return;
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "posterr",
"version": "1.18.1",
"version": "1.18.3",
"description": "A digital display for your media",
"main": "index.js",
"bin": "index.js",
Expand Down

0 comments on commit c9fe21c

Please sign in to comment.