Compare commits

..

2 Commits

Author SHA1 Message Date
MasterAcnolo
1bff8376b4 fix: force artifact name for exe 2026-08-04 22:04:20 +02:00
MasterAcnolo
3f44c01bd7 fix: refresh config at every download. Used by CreatePlaylistFolder 2026-08-04 22:03:55 +02:00
3 changed files with 32 additions and 7 deletions

View File

@@ -68,13 +68,30 @@ function loadFeatures() {
return JSON.parse(raw); 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. * In-memory snapshot of application feature flags.
* *
* Note: Changes to the config file are not automatically reflected. * Note: Changes to the config file are not automatically reflected.
* A restart or reload is required. * A restart or reload is required.
*/ */
const configFeatures = loadFeatures(); let configFeatures = loadFeatures();
module.exports = { module.exports = {
/** /**
@@ -102,6 +119,11 @@ module.exports = {
*/ */
configFeatures, configFeatures,
/**
* Function to reload the config
*/
reloadFeatures,
/** /**
* Path to the active configuration file * Path to the active configuration file
*/ */

View File

@@ -99,7 +99,7 @@
"win": { "win": {
"target": "nsis", "target": "nsis",
"icon": "build/app-icon.ico", "icon": "build/app-icon.ico",
"artifactName": "${productName}-Setup-${version}.${ext}", "artifactName": "Freedom-Loader-Setup-${version}.${ext}",
"extraResources": [ "extraResources": [
{ {
"from": "resources/binaries/win-32/yt-dlp.exe", "from": "resources/binaries/win-32/yt-dlp.exe",

View File

@@ -6,7 +6,7 @@ const { buildYtDlpArgs } = require("../helpers/buildArgs.helpers");
const notify = require("../helpers/notify.helpers"); const notify = require("../helpers/notify.helpers");
const path = require("path"); const path = require("path");
const { isSafePath } = require("../helpers/validation.helpers"); const { isSafePath } = require("../helpers/validation.helpers");
const { configFeatures } = require("../../config.js"); const {reloadFeatures} = require("../../config");
/** /**
* Reference to the currently running yt-dlp process. * Reference to the currently running yt-dlp process.
@@ -135,7 +135,10 @@ function createPlaylistFolder(basePath, playlistTitle) {
function fetchDownload(options, listeners, speedListeners, stageListeners, playlistInfoListeners) { function fetchDownload(options, listeners, speedListeners, stageListeners, playlistInfoListeners) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
logger.info(`CONFIG createPlaylistFolders: ${configFeatures.createPlaylistFolders}`);
const userConfig = reloadFeatures();
logger.info(`CONFIG createPlaylistFolders: ${userConfig.createPlaylistFolders}`);
let outputFolder = options.outputFolder || defaultDownloadFolder; let outputFolder = options.outputFolder || defaultDownloadFolder;
@@ -159,7 +162,7 @@ function fetchDownload(options, listeners, speedListeners, stageListeners, playl
// Détecte si c'est une playlist et crée un dossier approprié // Détecte si c'est une playlist et crée un dossier approprié
const isPlaylist = options.playlistTitle || isPlaylistUrl(options.url); const isPlaylist = options.playlistTitle || isPlaylistUrl(options.url);
if (isPlaylist && configFeatures.createPlaylistFolders) { if (isPlaylist && userConfig.createPlaylistFolders) {
try { try {
const playlistName = options.playlistTitle || "Untitled Playlist"; const playlistName = options.playlistTitle || "Untitled Playlist";
safeOutputFolder = createPlaylistFolder(safeOutputFolder, playlistName); safeOutputFolder = createPlaylistFolder(safeOutputFolder, playlistName);
@@ -168,7 +171,7 @@ function fetchDownload(options, listeners, speedListeners, stageListeners, playl
logger.error(`Failed to create playlist folder: ${err.message}`); logger.error(`Failed to create playlist folder: ${err.message}`);
return reject(err); return reject(err);
} }
} else if (isPlaylist && !configFeatures.createPlaylistFolders) { } else if (isPlaylist && !userConfig.createPlaylistFolders) {
logger.info(`Playlist detected but createPlaylistFolders is disabled, using base folder`); logger.info(`Playlist detected but createPlaylistFolders is disabled, using base folder`);
} }