fix: refresh config at every download. Used by CreatePlaylistFolder

This commit is contained in:
MasterAcnolo
2026-08-04 22:03:55 +02:00
committed by MasterAcnolo
parent 32eb849808
commit 9f85acbb59
2 changed files with 31 additions and 6 deletions

View File

@@ -68,13 +68,30 @@ function loadFeatures() {
return JSON.parse(raw);
}
/**
* Reloads feature flags from disk.
* Use this instead of the cached configFeatures snapshot
* when you need the latest user settings at call time.
*
* @returns {Object} Fresh feature flags from config file
*/
function reloadFeatures() {
try {
const raw = fs.readFileSync(featuresPath, "utf-8");
return JSON.parse(raw);
} catch (err) {
// Fallback to cached snapshot if file read fails
return configFeatures;
}
}
/**
* In-memory snapshot of application feature flags.
*
* Note: Changes to the config file are not automatically reflected.
* A restart or reload is required.
*/
const configFeatures = loadFeatures();
let configFeatures = loadFeatures();
module.exports = {
/**
@@ -102,6 +119,11 @@ module.exports = {
*/
configFeatures,
/**
* Function to reload the config
*/
reloadFeatures,
/**
* Path to the active configuration file
*/