Fix: Centralize resource paths and icons

This commit is contained in:
MasterAcnolo
2026-02-17 21:28:46 +01:00
parent 334e83ae1f
commit 760550e521
3 changed files with 51 additions and 25 deletions

22
main.js
View File

@@ -30,11 +30,14 @@ const gotLock = app.requestSingleInstanceLock();
// Native dependencies check (yt-dlp.exe, ffmpeg.exe, ffprobe.exe, Deno) // Native dependencies check (yt-dlp.exe, ffmpeg.exe, ffprobe.exe, Deno)
function checkNativeDependencies() { function checkNativeDependencies() {
// Import des chemins centralisés après l'initialisation de l'app
const { binaryPaths } = require("./server/helpers/path");
const deps = [ const deps = [
{ name: "yt-dlp.exe", path: path.join(process.resourcesPath, "binaries","yt-dlp.exe") }, { name: "yt-dlp.exe", path: binaryPaths.ytDlp },
{ name: "ffmpeg.exe", path: path.join(process.resourcesPath, "binaries", "ffmpeg.exe") }, { name: "ffmpeg.exe", path: binaryPaths.ffmpeg },
{ name: "ffprobe.exe", path: path.join(process.resourcesPath, "binaries", "ffprobe.exe") }, { name: "ffprobe.exe", path: binaryPaths.ffprobe },
{ name: "deno.exe", path: path.join(process.resourcesPath, "binaries", "deno.exe") }, { name: "deno.exe", path: binaryPaths.deno },
]; ];
const missing = deps.filter(dep => !fs.existsSync(dep.path)); const missing = deps.filter(dep => !fs.existsSync(dep.path));
let errorMsg = ""; let errorMsg = "";
@@ -114,6 +117,7 @@ function validateDownloadPath(userPath) {
if (!userPath) return path.join(userHome, "Downloads", "Freedom Loader"); if (!userPath) return path.join(userHome, "Downloads", "Freedom Loader");
try {
// Résolution canonique et suivi des symlinks // Résolution canonique et suivi des symlinks
const resolved = fs.realpathSync(path.resolve(userPath)); const resolved = fs.realpathSync(path.resolve(userPath));
const normalizedHome = path.resolve(userHome) + path.sep; const normalizedHome = path.resolve(userHome) + path.sep;
@@ -123,6 +127,10 @@ function validateDownloadPath(userPath) {
} }
return resolved; return resolved;
} catch (err) {
logger.error(`Invalid download path: ${userPath} - ${err.message}`);
throw new Error(`Chemin invalide ou inaccessible : ${err.message}`);
}
} }
@@ -267,8 +275,8 @@ app.on("window-all-closed", () => {
app.quit(); app.quit();
}); });
app.on("before-quit", () => { app.on("before-quit", async () => {
stopRPC() await stopRPC();
logger.info("All Services Stopped. Have a nice day!") logger.info("All Services Stopped. Have a nice day!")
logSessionEnd() logSessionEnd();
}); });

View File

@@ -1,12 +1,11 @@
const { Notification, shell } = require("electron"); const { Notification, shell } = require("electron");
const path = require("path"); const { iconPaths } = require("./path");
function notifyDownloadFinished(folder) { function notifyDownloadFinished(folder) {
const iconPath = path.join(process.resourcesPath, "confirm-icon.png");
const notif = new Notification({ const notif = new Notification({
title: "Freedom Loader", title: "Freedom Loader",
body: "Your download is complete, click here to open it.", body: "Your download is complete, click here to open it.",
icon: iconPath, icon: iconPaths.confirm,
}); });
notif.on("click", () => shell.openPath(folder)); notif.on("click", () => shell.openPath(folder));
@@ -14,11 +13,10 @@ function notifyDownloadFinished(folder) {
} }
function notifyCookiesBrowserError(){ function notifyCookiesBrowserError(){
const iconPath = path.join(process.resourcesPath, "error.png");
const notif = new Notification({ const notif = new Notification({
title: "Cookies Error", title: "Cookies Error",
body: "Unable to retrieve cookies. Please log in to your browser and click here to view the tutorial.", body: "Unable to retrieve cookies. Please log in to your browser and click here to view the tutorial.",
icon: iconPath, icon: iconPaths.error,
}); });
notif.on("click", () => shell.openExternal("https://youtube.com/shorts/cN9f4s1Mf88?si=519QCVd_-fzJqRf1")); notif.on("click", () => shell.openExternal("https://youtube.com/shorts/cN9f4s1Mf88?si=519QCVd_-fzJqRf1"));
@@ -26,11 +24,10 @@ function notifyCookiesBrowserError(){
} }
function notifyFirefoxBrowserMissing(){ function notifyFirefoxBrowserMissing(){
const iconPath = path.join(process.ressourcesPath, "error.png");
const notif = new Notification({ const notif = new Notification({
title: "Firefox Missing", title: "Firefox Missing",
body: "Firefox was not found on your system. Click here to follow the installation guide", body: "Firefox was not found on your system. Click here to follow the installation guide",
icon: iconPath, icon: iconPaths.error,
}); });
notif.on("click", () => shell.openExternal("https://youtube.com/shorts/cN9f4s1Mf88?si=519QCVd_-fzJqRf1")) notif.on("click", () => shell.openExternal("https://youtube.com/shorts/cN9f4s1Mf88?si=519QCVd_-fzJqRf1"))

View File

@@ -5,11 +5,17 @@ const config = require("../../config");
const { logger } = require("../logger.js"); const { logger } = require("../logger.js");
// Centralisation de tous les chemins de ressources
const resourcesPath = config.localMode
? path.join(__dirname, "../../ressources")
: process.resourcesPath;
// Chemins des binaires
let userYtDlp; let userYtDlp;
let ffmpegPath; let ffmpegPath;
let denoPath; let denoPath;
const sourceYtDlp = path.join(process.resourcesPath, "binaries","yt-dlp.exe"); const sourceYtDlp = path.join(resourcesPath, "binaries","yt-dlp.exe");
if (config.localMode) { if (config.localMode) {
userYtDlp = path.join(__dirname, "../../ressources/yt-dlp.exe"); userYtDlp = path.join(__dirname, "../../ressources/yt-dlp.exe");
@@ -17,8 +23,8 @@ if (config.localMode) {
denoPath = path.join(__dirname, "../../ressources/deno.exe"); denoPath = path.join(__dirname, "../../ressources/deno.exe");
} else { } else {
userYtDlp = path.join(app.getPath("userData"),"yt-dlp.exe"); userYtDlp = path.join(app.getPath("userData"),"yt-dlp.exe");
ffmpegPath = path.join(process.resourcesPath, "binaries","ffmpeg.exe"); ffmpegPath = path.join(resourcesPath, "binaries","ffmpeg.exe");
denoPath = path.join(process.resourcesPath, "binaries","deno.exe"); denoPath = path.join(resourcesPath, "binaries","deno.exe");
if (!fs.existsSync(userYtDlp)) { if (!fs.existsSync(userYtDlp)) {
fs.copyFileSync(sourceYtDlp, userYtDlp); fs.copyFileSync(sourceYtDlp, userYtDlp);
@@ -26,8 +32,23 @@ if (config.localMode) {
} }
// Chemins des icônes de notification
const iconPaths = {
confirm: path.join(resourcesPath, "confirm-icon.png"),
error: path.join(resourcesPath, "error.png"),
app: path.join(resourcesPath, "app-icon.ico")
};
// Chemins des binaires pour vérification
const binaryPaths = {
ytDlp: path.join(resourcesPath, "binaries", "yt-dlp.exe"),
ffmpeg: path.join(resourcesPath, "binaries", "ffmpeg.exe"),
ffprobe: path.join(resourcesPath, "binaries", "ffprobe.exe"),
deno: path.join(resourcesPath, "binaries", "deno.exe")
};
if (!userYtDlp){ logger.error("Missing YT-DLP")} if (!userYtDlp){ logger.error("Missing YT-DLP")}
if (!ffmpegPath){ logger.error("Missing FFMPEG")} if (!ffmpegPath){ logger.error("Missing FFMPEG")}
if (!denoPath){ logger.error("Missing DENO")} if (!denoPath){ logger.error("Missing DENO")}
module.exports = { userYtDlp, ffmpegPath, denoPath }; module.exports = { userYtDlp, ffmpegPath, denoPath, iconPaths, binaryPaths, resourcesPath };