sync: to work on windows

This commit is contained in:
MasterAcnolo
2026-07-25 11:32:48 +02:00
parent 90d8a9f65d
commit 1ff32ca021
2 changed files with 44 additions and 25 deletions

View File

@@ -79,7 +79,7 @@ const { updateYtDlp } = require("./app/ytDlpUpdater");
const { createMainWindow, getMainWindow } = require("./app/windowManager");
const { registerIpcHandlers } = require("./app/ipcHandlers");
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
validateBinaries();
initUserThemes();
await initThemes(userThemesPath);

View File

@@ -164,7 +164,7 @@ function initUserThemes() {
if (!fs.existsSync(userThemesPath)) {
fs.mkdirSync(userThemesPath, { recursive: true });
fs.chmodSync(userThemesPath, 0o777);
getLogger().info("Created user themes directory");
getLogger().info("Created user themes directory");
}
if (fs.existsSync(defaultThemesSourcePath)) {
@@ -172,27 +172,37 @@ function initUserThemes() {
for (const theme of defaultThemes) {
const srcPath = path.join(defaultThemesSourcePath, theme);
const destPath = path.join(userThemesPath, theme);
const srcIsFile = !fs.statSync(srcPath).isDirectory();
if (!fs.existsSync(destPath)) {
try {
if (fs.statSync(srcPath).isDirectory()) {
copyDirectory(srcPath, destPath);
fs.chmodSync(destPath, 0o777);
} 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}`);
if (fs.existsSync(destPath)) {
const destIsDir = fs.statSync(destPath).isDirectory();
if (srcIsFile && destIsDir) {
getLogger().warn(`Corrupted theme entry: ${theme}, fixing...`);
fs.rmSync(destPath, { recursive: true, force: true });
} else {
continue;
}
}
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 {
getLogger().warn(`Default themes source path not found: ${defaultThemesSourcePath}`);
getLogger().warn(`Default themes source path not found: ${defaultThemesSourcePath}`);
}
} 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
if (!userYtDlp) {
getLogger().error("Missing yt-dlp binary");
}
// if (!userYtDlp) {
// getLogger().error("Missing yt-dlp binary");
// }
if (!ffmpegPath) {
getLogger().error("Missing ffmpeg binary");
}
// if (!ffmpegPath) {
// getLogger().error("Missing ffmpeg binary");
// }
if (!denoPath) {
getLogger().error("Missing deno binary");
// if (!denoPath) {
// 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;
}
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 };