(filename: string, downloadFolder?: string | null)
| 17 | |
| 18 | |
| 19 | export function getPathToDownloadsDirectory(filename: string, downloadFolder?: string | null): string { |
| 20 | let targetPath: string; |
| 21 | |
| 22 | if (downloadFolder && downloadFolder.trim() !== '') { |
| 23 | // Use custom download folder |
| 24 | targetPath = downloadFolder; |
| 25 | targetPath = path.join(targetPath, electronConfig.productName); |
| 26 | } else { |
| 27 | // Use default downloads path |
| 28 | const downloadsPath = electronConfig.downloadsPath; |
| 29 | targetPath = path.join(downloadsPath, electronConfig.productName); |
| 30 | } |
| 31 | |
| 32 | if (!fs.existsSync(targetPath)) { |
| 33 | fs.mkdirSync(targetPath, { recursive: true }); |
| 34 | } |
| 35 | |
| 36 | const filePath = path.join(targetPath, filename); |
| 37 | |
| 38 | return filePath; |
| 39 | } |
| 40 | |
| 41 | export function getTargetDirectoryPath() { |
| 42 | if (isElectron) { |
no test coverage detected