Skip to content

Commit 85ed0e0

Browse files
committed
Add error message from opening database
1 parent c908081 commit 85ed0e0

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

share/translations/keepassxc_en.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2446,7 +2446,7 @@ The command has to exit. In case of `sftp` as last command `exit` has to be sent
24462446
<translation type="unfinished"></translation>
24472447
</message>
24482448
<message>
2449-
<source>Download finished, but file failed KeePass header check. File is not a KeePass file or it&apos;s an unsupported version</source>
2449+
<source>Downloaded file is not a KeePass file or it&apos;s an unsupported version: %1</source>
24502450
<translation type="unfinished"></translation>
24512451
</message>
24522452
<message>

src/gui/remote/DatabaseSettingsWidgetRemote.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,12 @@ void DatabaseSettingsWidgetRemote::testDownload()
187187
params->downloadInput = m_ui->inputForDownload->toPlainText();
188188
params->downloadTimeoutMsec = m_ui->downloadTimeoutSec->value() * 1000;
189189

190-
QScopedPointer<RemoteHandler> remoteHandler(new RemoteHandler(this));
191190
if (params->downloadCommand.isEmpty()) {
192191
m_ui->messageWidget->showMessage(tr("Download command cannot be empty."), MessageWidget::Warning);
193192
return;
194193
}
195194

195+
QScopedPointer<RemoteHandler> remoteHandler(new RemoteHandler(this));
196196
RemoteHandler::RemoteResult result = remoteHandler->download(params);
197197
if (!result.success) {
198198
m_ui->messageWidget->showMessage(tr("Download failed with error: %1").arg(result.errorMessage),
@@ -206,19 +206,20 @@ void DatabaseSettingsWidgetRemote::testDownload()
206206
return;
207207
}
208208

209-
if (!hasValidPublicHeaders(result.filePath)) {
210-
m_ui->messageWidget->showMessage(tr("Download finished, but file failed KeePass header check. File is not a "
211-
"KeePass file or it's an unsupported version"),
212-
MessageWidget::Error);
209+
QString error;
210+
if (!hasValidPublicHeader(result.filePath, &error)) {
211+
m_ui->messageWidget->showMessage(
212+
tr("Downloaded file is not a KeePass file or it's an unsupported version: %1").arg(error),
213+
MessageWidget::Error);
213214
return;
214215
}
215216

216217
m_ui->messageWidget->showMessage(tr("Download successful."), MessageWidget::Positive);
217218
}
218219

219-
bool DatabaseSettingsWidgetRemote::hasValidPublicHeaders(QString& filePath) {
220+
bool DatabaseSettingsWidgetRemote::hasValidPublicHeader(QString& filePath, QString* error)
221+
{
220222
// Read public headers
221-
QString error;
222223
QScopedPointer<Database> db(new Database());
223-
return db->open(filePath, nullptr, &error);
224+
return db->open(filePath, nullptr, error);
224225
}

src/gui/remote/DatabaseSettingsWidgetRemote.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ private slots:
5656
QListWidgetItem* findItemByName(const QString& name);
5757
void clearFields();
5858

59-
bool hasValidPublicHeaders(QString& filePath);
59+
bool hasValidPublicHeader(QString& filePath, QString* error);
6060

6161
QScopedPointer<RemoteSettings> m_remoteSettings;
6262
const QScopedPointer<Ui::DatabaseSettingsWidgetRemote> m_ui;

0 commit comments

Comments
 (0)