Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion app/main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2017 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only

import { join, normalize, extname, dirname, basename } from 'path';
import { join, normalize, extname, dirname, basename, isAbsolute } from 'path';
import { pathToFileURL } from 'url';
import * as os from 'os';
import { chmod, realpath, writeFile } from 'fs-extra';
Expand Down Expand Up @@ -3021,6 +3021,30 @@ ipc.handle('show-save-dialog', async (_event, { defaultPath }) => {
return { canceled: true };
}

if (
process.platform === 'linux' &&
defaultPath &&
!isAbsolute(defaultPath)
) {
// On Linux the defaultPath should be an absolute path, otherwise the save dialog will have an empty filename on KDE/Plasma
let downloadsPath = '';
try {
downloadsPath = app.getPath('downloads');
getLogger().info(
'show-save-dialog: saving to user downloads directory: ' + downloadsPath
);
} catch (e) {
// If we cannot get Downloads path, fall back to the user's home directory
downloadsPath = app.getPath('home');
getLogger().info(
'show-save-dialog: saving to user home directory: ' + downloadsPath
);
}
if (downloadsPath) {
defaultPath = join(downloadsPath, defaultPath)
}
}

const { canceled, filePath: selectedFilePath } = await dialog.showSaveDialog(
mainWindow,
{
Expand Down