mirror of
https://github.com/MasterAcnolo/Freedom-Loader.git
synced 2026-07-29 18:25:47 +02:00
sync: to work on windows
This commit is contained in:
4
main.js
4
main.js
@@ -79,7 +79,7 @@ const { updateYtDlp } = require("./app/ytDlpUpdater");
|
|||||||
const { createMainWindow, getMainWindow } = require("./app/windowManager");
|
const { createMainWindow, getMainWindow } = require("./app/windowManager");
|
||||||
const { registerIpcHandlers } = require("./app/ipcHandlers");
|
const { registerIpcHandlers } = require("./app/ipcHandlers");
|
||||||
const { createSplashWindow, closeSplashWindow, setSplashProgress } = require("./app/splashManager");
|
const { createSplashWindow, closeSplashWindow, setSplashProgress } = require("./app/splashManager");
|
||||||
const { userThemesPath, initUserThemes, isWindows } = require("./server/helpers/path.helpers");
|
const { userThemesPath, initUserThemes, isWindows, validateBinaries } = require("./server/helpers/path.helpers");
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -117,6 +117,8 @@ app.whenReady().then(async () => {
|
|||||||
|
|
||||||
setSplashProgress(2); // Loading themes
|
setSplashProgress(2); // Loading themes
|
||||||
|
|
||||||
|
validateBinaries();
|
||||||
|
|
||||||
initUserThemes();
|
initUserThemes();
|
||||||
await initThemes(userThemesPath);
|
await initThemes(userThemesPath);
|
||||||
|
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ function initUserThemes() {
|
|||||||
if (!fs.existsSync(userThemesPath)) {
|
if (!fs.existsSync(userThemesPath)) {
|
||||||
fs.mkdirSync(userThemesPath, { recursive: true });
|
fs.mkdirSync(userThemesPath, { recursive: true });
|
||||||
fs.chmodSync(userThemesPath, 0o777);
|
fs.chmodSync(userThemesPath, 0o777);
|
||||||
getLogger().info("Created user themes directory");
|
getLogger().info("Created user themes directory");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fs.existsSync(defaultThemesSourcePath)) {
|
if (fs.existsSync(defaultThemesSourcePath)) {
|
||||||
@@ -172,27 +172,37 @@ function initUserThemes() {
|
|||||||
for (const theme of defaultThemes) {
|
for (const theme of defaultThemes) {
|
||||||
const srcPath = path.join(defaultThemesSourcePath, theme);
|
const srcPath = path.join(defaultThemesSourcePath, theme);
|
||||||
const destPath = path.join(userThemesPath, theme);
|
const destPath = path.join(userThemesPath, theme);
|
||||||
|
const srcIsFile = !fs.statSync(srcPath).isDirectory();
|
||||||
|
|
||||||
if (!fs.existsSync(destPath)) {
|
if (fs.existsSync(destPath)) {
|
||||||
try {
|
const destIsDir = fs.statSync(destPath).isDirectory();
|
||||||
if (fs.statSync(srcPath).isDirectory()) {
|
if (srcIsFile && destIsDir) {
|
||||||
copyDirectory(srcPath, destPath);
|
getLogger().warn(`Corrupted theme entry: ${theme}, fixing...`);
|
||||||
fs.chmodSync(destPath, 0o777);
|
fs.rmSync(destPath, { recursive: true, force: true });
|
||||||
} else {
|
|
||||||
fs.copyFileSync(srcPath, destPath);
|
} else {
|
||||||
fs.chmodSync(destPath, 0o666);
|
continue;
|
||||||
}
|
|
||||||
getLogger().info(`Copied default theme: ${theme}`);
|
|
||||||
} catch (copyErr) {
|
|
||||||
getLogger().warn(`Failed to copy theme ${theme}: ${copyErr.message}`);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (srcIsFile) {
|
||||||
|
fs.copyFileSync(srcPath, destPath);
|
||||||
|
fs.chmodSync(destPath, 0o666);
|
||||||
|
} else {
|
||||||
|
copyDirectory(srcPath, destPath);
|
||||||
|
fs.chmodSync(destPath, 0o777);
|
||||||
|
}
|
||||||
|
getLogger().info(`Copied default theme: ${theme}`);
|
||||||
|
} catch (copyErr) {
|
||||||
|
getLogger().warn(`Failed to copy theme ${theme}: ${copyErr.message}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
getLogger().warn(`Default themes source path not found: ${defaultThemesSourcePath}`);
|
getLogger().warn(`Default themes source path not found: ${defaultThemesSourcePath}`);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
getLogger().error(`Failed to initialize user themes: ${err.message}`);
|
getLogger().error(`Failed to initialize user themes: ${err.message}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@@ -229,16 +239,23 @@ function copyDirectory(src, dest) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Runtime validation of critical binaries
|
// Runtime validation of critical binaries
|
||||||
if (!userYtDlp) {
|
// if (!userYtDlp) {
|
||||||
getLogger().error("Missing yt-dlp binary");
|
// getLogger().error("Missing yt-dlp binary");
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (!ffmpegPath) {
|
// if (!ffmpegPath) {
|
||||||
getLogger().error("Missing ffmpeg binary");
|
// getLogger().error("Missing ffmpeg binary");
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (!denoPath) {
|
// if (!denoPath) {
|
||||||
getLogger().error("Missing deno binary");
|
// getLogger().error("Missing deno binary");
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
function validateBinaries() {
|
||||||
|
if (!userYtDlp) getLogger().error("Missing yt-dlp binary");
|
||||||
|
if (!ffmpegPath) getLogger().error("Missing ffmpeg binary");
|
||||||
|
if (!denoPath) getLogger().error("Missing deno binary");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -249,4 +266,4 @@ function getLogger() {
|
|||||||
return require("../logger.js").logger;
|
return require("../logger.js").logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { userYtDlp, ffmpegPath, denoPath, iconPaths, binaryPaths, resourcesPath, defaultDownloadFolder, userThemesPath, initUserThemes, isWindows };
|
module.exports = { userYtDlp, ffmpegPath, denoPath, iconPaths, binaryPaths, resourcesPath, defaultDownloadFolder, userThemesPath, initUserThemes, isWindows, validateBinaries };
|
||||||
Reference in New Issue
Block a user