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
|
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();
|
initUserThemes();
|
||||||
await initThemes(userThemesPath);
|
await initThemes(userThemesPath);
|
||||||
} else {
|
|
||||||
logger.info(`OS is ${process.platform}, Skipping themes loading`)
|
|
||||||
}
|
|
||||||
|
|
||||||
setSplashProgress(3); // Almost ready
|
setSplashProgress(3); // Almost ready
|
||||||
await createMainWindow();
|
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 { app } = require("electron");
|
||||||
const config = require("../../config.js");
|
const config = require("../../config.js");
|
||||||
|
|
||||||
const { logger } = require("../logger.js");
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is the OS windows
|
* Is the OS windows
|
||||||
*/
|
*/
|
||||||
@@ -104,7 +102,7 @@ if (config.devMode) {
|
|||||||
try {
|
try {
|
||||||
fs.chmodSync(userYtDlp, 0o755);
|
fs.chmodSync(userYtDlp, 0o755);
|
||||||
} catch (err) {
|
} 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 {
|
try {
|
||||||
if (!fs.existsSync(userThemesPath)) {
|
if (!fs.existsSync(userThemesPath)) {
|
||||||
fs.mkdirSync(userThemesPath, { recursive: true });
|
fs.mkdirSync(userThemesPath, { recursive: true });
|
||||||
// Ensure folder is writable
|
|
||||||
fs.chmodSync(userThemesPath, 0o777);
|
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)) {
|
if (fs.existsSync(defaultThemesSourcePath)) {
|
||||||
const defaultThemes = fs.readdirSync(defaultThemesSourcePath);
|
const defaultThemes = fs.readdirSync(defaultThemesSourcePath);
|
||||||
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);
|
||||||
|
|
||||||
if (!fs.existsSync(destPath)) {
|
if (!fs.existsSync(destPath)) {
|
||||||
try {
|
try {
|
||||||
|
if (fs.statSync(srcPath).isDirectory()) {
|
||||||
copyDirectory(srcPath, destPath);
|
copyDirectory(srcPath, destPath);
|
||||||
fs.chmodSync(destPath, 0o777);
|
fs.chmodSync(destPath, 0o777);
|
||||||
logger.info(`Copied default theme: ${theme}`);
|
} else {
|
||||||
} catch (copyErr) {
|
fs.copyFileSync(srcPath, destPath);
|
||||||
logger.warn(
|
fs.chmodSync(destPath, 0o666);
|
||||||
`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}`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
getLogger().info(`Copied default theme: ${theme}`);
|
||||||
|
} catch (copyErr) {
|
||||||
|
getLogger().warn(`Failed to copy theme ${theme}: ${copyErr.message}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
logger.warn(
|
getLogger().warn(`Default themes source path not found: ${defaultThemesSourcePath}`);
|
||||||
`Default themes source path not found: ${defaultThemesSourcePath}`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} 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.
|
* Recursively copies a directory and its contents.
|
||||||
*
|
*
|
||||||
@@ -242,15 +230,23 @@ function copyDirectory(src, dest) {
|
|||||||
|
|
||||||
// Runtime validation of critical binaries
|
// Runtime validation of critical binaries
|
||||||
if (!userYtDlp) {
|
if (!userYtDlp) {
|
||||||
logger.error("Missing yt-dlp binary");
|
getLogger().error("Missing yt-dlp binary");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ffmpegPath) {
|
if (!ffmpegPath) {
|
||||||
logger.error("Missing ffmpeg binary");
|
getLogger().error("Missing ffmpeg binary");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!denoPath) {
|
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 };
|
module.exports = { userYtDlp, ffmpegPath, denoPath, iconPaths, binaryPaths, resourcesPath, defaultDownloadFolder, userThemesPath, initUserThemes, isWindows };
|
||||||
Reference in New Issue
Block a user