double check out dir type

closes #2719
closes #2724
pull/2734/head
Mikael Finstad 5 months ago
parent 260128e576
commit 26012871f1
No known key found for this signature in database
GPG Key ID: 25AB36E3E81CBC26

@ -17,6 +17,7 @@ import getSwal from '../swal';
import isDev from '../isDev';
import mainApi from '../mainApi';
const { lstat } = window.require('fs/promises');
const remote = window.require('@electron/remote');
const { dialog } = remote;
@ -76,7 +77,16 @@ export async function askForOutDir(defaultPath?: string | undefined) {
message: i18n.t('Where do you want to save output files? Make sure there is enough free space in this folder'),
buttonLabel: i18n.t('Select output folder'),
});
return (filePaths && filePaths.length === 1) ? filePaths[0] : undefined;
const [filePath] = filePaths;
if (!filePath || filePaths.length !== 1) {
return undefined;
}
// sanity check for directory. Don't trust showOpenDialog 100%, see https://github.com/mifi/lossless-cut/issues/2719
if (!(await lstat(filePath)).isDirectory()) {
console.warn('Selected output path is not a directory', filePath);
return undefined;
}
return filePath;
}
export async function askForFfPath(defaultPath?: string | undefined) {

Loading…
Cancel
Save