diff --git a/share/translations/keepassxc_en.ts b/share/translations/keepassxc_en.ts index 51282074f9..c88a420c6e 100644 --- a/share/translations/keepassxc_en.ts +++ b/share/translations/keepassxc_en.ts @@ -2369,7 +2369,7 @@ The command has to exit. In case of `sftp` as last command `exit` has to be sent - Download finished, but file failed KeePass header check. File is not a KeePass file or it's an unsupported version + Downloaded file is not a KeePass file or it's an unsupported version: %1 diff --git a/src/gui/remote/DatabaseSettingsWidgetRemote.cpp b/src/gui/remote/DatabaseSettingsWidgetRemote.cpp index dce1238776..6d9135de02 100644 --- a/src/gui/remote/DatabaseSettingsWidgetRemote.cpp +++ b/src/gui/remote/DatabaseSettingsWidgetRemote.cpp @@ -178,12 +178,12 @@ void DatabaseSettingsWidgetRemote::testDownload() params->downloadCommand = m_ui->downloadCommand->text(); params->downloadInput = m_ui->inputForDownload->toPlainText(); - QScopedPointer remoteHandler(new RemoteHandler(this)); if (params->downloadCommand.isEmpty()) { m_ui->messageWidget->showMessage(tr("Download command cannot be empty."), MessageWidget::Warning); return; } + QScopedPointer remoteHandler(new RemoteHandler(this)); RemoteHandler::RemoteResult result = remoteHandler->download(params); if (!result.success) { m_ui->messageWidget->showMessage(tr("Download failed with error: %1").arg(result.errorMessage), @@ -197,19 +197,20 @@ void DatabaseSettingsWidgetRemote::testDownload() return; } - if (!hasValidPublicHeaders(result.filePath)) { - m_ui->messageWidget->showMessage(tr("Download finished, but file failed KeePass header check. File is not a " - "KeePass file or it's an unsupported version"), - MessageWidget::Error); + QString error; + if (!hasValidPublicHeader(result.filePath, &error)) { + m_ui->messageWidget->showMessage( + tr("Downloaded file is not a KeePass file or it's an unsupported version: %1").arg(error), + MessageWidget::Error); return; } m_ui->messageWidget->showMessage(tr("Download successful."), MessageWidget::Positive); } -bool DatabaseSettingsWidgetRemote::hasValidPublicHeaders(QString& filePath) { +bool DatabaseSettingsWidgetRemote::hasValidPublicHeader(QString& filePath, QString* error) +{ // Read public headers - QString error; QScopedPointer db(new Database()); - return db->open(filePath, nullptr, &error); -} \ No newline at end of file + return db->open(filePath, nullptr, error); +} diff --git a/src/gui/remote/DatabaseSettingsWidgetRemote.h b/src/gui/remote/DatabaseSettingsWidgetRemote.h index 8f77498d65..c5e384445c 100644 --- a/src/gui/remote/DatabaseSettingsWidgetRemote.h +++ b/src/gui/remote/DatabaseSettingsWidgetRemote.h @@ -56,7 +56,7 @@ private slots: QListWidgetItem* findItemByName(const QString& name); void clearFields(); - bool hasValidPublicHeaders(QString& filePath); + bool hasValidPublicHeader(QString& filePath, QString* error); QScopedPointer m_remoteSettings; const QScopedPointer m_ui;