mirror of
https://github.com/MasterAcnolo/Freedom-Loader.git
synced 2026-07-29 18:25:47 +02:00
Fix: Centralize resource paths and icons
This commit is contained in:
36
main.js
36
main.js
@@ -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,15 +117,20 @@ function validateDownloadPath(userPath) {
|
|||||||
|
|
||||||
if (!userPath) return path.join(userHome, "Downloads", "Freedom Loader");
|
if (!userPath) return path.join(userHome, "Downloads", "Freedom Loader");
|
||||||
|
|
||||||
// Résolution canonique et suivi des symlinks
|
try {
|
||||||
const resolved = fs.realpathSync(path.resolve(userPath));
|
// Résolution canonique et suivi des symlinks
|
||||||
const normalizedHome = path.resolve(userHome) + path.sep;
|
const resolved = fs.realpathSync(path.resolve(userPath));
|
||||||
|
const normalizedHome = path.resolve(userHome) + path.sep;
|
||||||
|
|
||||||
if (!resolved.startsWith(normalizedHome)) {
|
if (!resolved.startsWith(normalizedHome)) {
|
||||||
throw new Error("Chemin non autorisé : uniquement les sous-dossiers du dossier utilisateur sont permis !");
|
throw new Error("Chemin non autorisé : uniquement les sous-dossiers du dossier utilisateur sont permis !");
|
||||||
|
}
|
||||||
|
|
||||||
|
return resolved;
|
||||||
|
} catch (err) {
|
||||||
|
logger.error(`Invalid download path: ${userPath} - ${err.message}`);
|
||||||
|
throw new Error(`Chemin invalide ou inaccessible : ${err.message}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
return resolved;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -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();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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"))
|
||||||
|
|||||||
@@ -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 };
|
||||||
|
|||||||
Reference in New Issue
Block a user