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 { 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);

View File

@@ -172,22 +172,32 @@ 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)) {
const destIsDir = fs.statSync(destPath).isDirectory();
if (srcIsFile && destIsDir) {
getLogger().warn(`Corrupted theme entry: ${theme}, fixing...`);
fs.rmSync(destPath, { recursive: true, force: true });
if (!fs.existsSync(destPath)) {
try {
if (fs.statSync(srcPath).isDirectory()) {
copyDirectory(srcPath, destPath);
fs.chmodSync(destPath, 0o777);
} else { } else {
continue;
}
}
try {
if (srcIsFile) {
fs.copyFileSync(srcPath, destPath); fs.copyFileSync(srcPath, destPath);
fs.chmodSync(destPath, 0o666); fs.chmodSync(destPath, 0o666);
} else {
copyDirectory(srcPath, destPath);
fs.chmodSync(destPath, 0o777);
} }
getLogger().info(`Copied default theme: ${theme}`); getLogger().info(`Copied default theme: ${theme}`);
} catch (copyErr) { } catch (copyErr) {
getLogger().warn(`Failed to copy theme ${theme}: ${copyErr.message}`); 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}`);
} }
@@ -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 };