mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-04-19 23:35:57 -04:00
Add KeePass header check for testing remote download (#10910)
This commit is contained in:
parent
4d7eae34c2
commit
c908081421
@ -2409,10 +2409,6 @@ removed from the database.</source>
|
||||
<source>Download failed with error: %1</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Download finished, but file %1 could not be found.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Download successful.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
@ -2445,6 +2441,14 @@ The command has to exit. In case of `sftp` as last command `exit` has to be sent
|
||||
</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Command finished, but downloaded file does not exist.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Download finished, but file failed KeePass header check. File is not a KeePass file or it's an unsupported version</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Timeout:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "DatabaseSettingsWidgetRemote.h"
|
||||
#include "ui_DatabaseSettingsWidgetRemote.h"
|
||||
|
||||
#include "core/Database.h"
|
||||
#include "core/Global.h"
|
||||
#include "core/Metadata.h"
|
||||
|
||||
@ -200,10 +201,24 @@ void DatabaseSettingsWidgetRemote::testDownload()
|
||||
}
|
||||
|
||||
if (!QFile::exists(result.filePath)) {
|
||||
m_ui->messageWidget->showMessage(tr("Download finished, but file %1 could not be found.").arg(result.filePath),
|
||||
m_ui->messageWidget->showMessage(tr("Command finished, but downloaded file does not exist."),
|
||||
MessageWidget::Error);
|
||||
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);
|
||||
return;
|
||||
}
|
||||
|
||||
m_ui->messageWidget->showMessage(tr("Download successful."), MessageWidget::Positive);
|
||||
}
|
||||
|
||||
bool DatabaseSettingsWidgetRemote::hasValidPublicHeaders(QString& filePath) {
|
||||
// Read public headers
|
||||
QString error;
|
||||
QScopedPointer<Database> db(new Database());
|
||||
return db->open(filePath, nullptr, &error);
|
||||
}
|
||||
|
@ -56,6 +56,8 @@ private:
|
||||
QListWidgetItem* findItemByName(const QString& name);
|
||||
void clearFields();
|
||||
|
||||
bool hasValidPublicHeaders(QString& filePath);
|
||||
|
||||
QScopedPointer<RemoteSettings> m_remoteSettings;
|
||||
const QScopedPointer<Ui::DatabaseSettingsWidgetRemote> m_ui;
|
||||
bool m_modified = false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user