Fix: Undo Path Validation for coming back on a classic one

This commit is contained in:
MasterAcnolo
2026-02-18 14:43:40 +01:00
parent 32c9a66a35
commit 74fcdbb738
4 changed files with 32 additions and 47 deletions

24
main.js
View File

@@ -143,23 +143,23 @@ function validateDownloadPath(userPath) {
// IPC
ipcMain.handle("select-download-folder", async () => {
try {
const result = await dialog.showOpenDialog({ properties: ["openDirectory"] });
if (result.canceled) {
logger.info("Folder selection cancelled by user");
return null;
}
if (result.filePaths.length > 0) {
const selectedPath = result.filePaths[0];
const result = await dialog.showOpenDialog({ properties: ["openDirectory"] });
if (result.canceled) {
logger.info("Folder selection cancelled by user");
return null;
}
if (result.filePaths.length > 0) {
const selectedPath = result.filePaths[0];
try {
const validatedPath = validateDownloadPath(selectedPath);
logger.info(`Folder selected and validated: ${validatedPath}`);
return validatedPath;
} catch (err) {
logger.warn(`Unsafe or invalid folder rejected: ${err.message}`);
throw err; // Propagate error to UI
}
return null;
} catch (err) {
logger.warn(`Unsafe or invalid folder rejected: ${err.message}`);
return null;
}
return null;
});
ipcMain.handle("validate-download-path", (event, userPath) => {