mirror of
https://github.com/MasterAcnolo/Freedom-Loader.git
synced 2026-07-29 18:25:47 +02:00
Compare commits
3 Commits
8b31436e25
...
90d8a9f65d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
90d8a9f65d | ||
|
|
d5965c2ce0 | ||
|
|
15f59a6093 |
6
main.js
6
main.js
@@ -117,14 +117,8 @@ app.whenReady().then(async () => {
|
||||
|
||||
setSplashProgress(2); // Loading themes
|
||||
|
||||
// TODO: Patch this, i disable this features for the moment
|
||||
// Themes are currently disabled if we are not on Windows
|
||||
if(isWindows){
|
||||
initUserThemes();
|
||||
await initThemes(userThemesPath);
|
||||
} else {
|
||||
logger.info(`OS is ${process.platform}, Skipping themes loading`)
|
||||
}
|
||||
|
||||
setSplashProgress(3); // Almost ready
|
||||
await createMainWindow();
|
||||
|
||||
@@ -25,6 +25,3 @@ async function initPlatformRestrictions() {
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function(){
|
||||
initPlatformRestrictions();
|
||||
})
|
||||
Binary file not shown.
@@ -3,8 +3,6 @@ const fs = require("fs");
|
||||
const { app } = require("electron");
|
||||
const config = require("../../config.js");
|
||||
|
||||
const { logger } = require("../logger.js");
|
||||
|
||||
/**
|
||||
* Is the OS windows
|
||||
*/
|
||||
@@ -104,7 +102,7 @@ if (config.devMode) {
|
||||
try {
|
||||
fs.chmodSync(userYtDlp, 0o755);
|
||||
} catch (err) {
|
||||
logger.warn(`Failed to chmod yt-dlp: ${err.message}`);
|
||||
getLogger().warn(`Failed to chmod yt-dlp: ${err.message}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -165,48 +163,38 @@ function initUserThemes() {
|
||||
try {
|
||||
if (!fs.existsSync(userThemesPath)) {
|
||||
fs.mkdirSync(userThemesPath, { recursive: true });
|
||||
// Ensure folder is writable
|
||||
fs.chmodSync(userThemesPath, 0o777);
|
||||
logger.info("Created user themes directory");
|
||||
getLogger().info("Created user themes directory");
|
||||
}
|
||||
|
||||
// Copy default themes from resources to user directory if they don't exist
|
||||
if (fs.existsSync(defaultThemesSourcePath)) {
|
||||
const defaultThemes = fs.readdirSync(defaultThemesSourcePath);
|
||||
for (const theme of defaultThemes) {
|
||||
const srcPath = path.join(defaultThemesSourcePath, theme);
|
||||
const destPath = path.join(userThemesPath, theme);
|
||||
|
||||
if (!fs.existsSync(destPath)) {
|
||||
try {
|
||||
if (fs.statSync(srcPath).isDirectory()) {
|
||||
copyDirectory(srcPath, destPath);
|
||||
fs.chmodSync(destPath, 0o777);
|
||||
logger.info(`Copied default theme: ${theme}`);
|
||||
} catch (copyErr) {
|
||||
logger.warn(
|
||||
`Failed to copy theme ${theme}: ${copyErr.message}. Theme folder will be created, add theme files manually.`
|
||||
);
|
||||
|
||||
try {
|
||||
fs.mkdirSync(destPath, { recursive: true });
|
||||
fs.chmodSync(destPath, 0o777);
|
||||
} catch (mkdirErr) {
|
||||
logger.warn(
|
||||
`Could not create theme directory ${theme}: ${mkdirErr.message}`
|
||||
);
|
||||
} else {
|
||||
fs.copyFileSync(srcPath, destPath);
|
||||
fs.chmodSync(destPath, 0o666);
|
||||
}
|
||||
getLogger().info(`Copied default theme: ${theme}`);
|
||||
} catch (copyErr) {
|
||||
getLogger().warn(`Failed to copy theme ${theme}: ${copyErr.message}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
logger.warn(
|
||||
`Default themes source path not found: ${defaultThemesSourcePath}`
|
||||
);
|
||||
getLogger().warn(`Default themes source path not found: ${defaultThemesSourcePath}`);
|
||||
}
|
||||
} catch (err) {
|
||||
logger.error(`Failed to initialize user themes: ${err.message}`);
|
||||
getLogger().error(`Failed to initialize user themes: ${err.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively copies a directory and its contents.
|
||||
*
|
||||
@@ -242,15 +230,23 @@ function copyDirectory(src, dest) {
|
||||
|
||||
// Runtime validation of critical binaries
|
||||
if (!userYtDlp) {
|
||||
logger.error("Missing yt-dlp binary");
|
||||
getLogger().error("Missing yt-dlp binary");
|
||||
}
|
||||
|
||||
if (!ffmpegPath) {
|
||||
logger.error("Missing ffmpeg binary");
|
||||
getLogger().error("Missing ffmpeg binary");
|
||||
}
|
||||
|
||||
if (!denoPath) {
|
||||
logger.error("Missing deno binary");
|
||||
getLogger().error("Missing deno binary");
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to lazy load logger, avoid circular import
|
||||
* @returns {winston.Logger}
|
||||
*/
|
||||
function getLogger() {
|
||||
return require("../logger.js").logger;
|
||||
}
|
||||
|
||||
module.exports = { userYtDlp, ffmpegPath, denoPath, iconPaths, binaryPaths, resourcesPath, defaultDownloadFolder, userThemesPath, initUserThemes, isWindows };
|
||||
Reference in New Issue
Block a user