-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add KeePass header check for testing remote download (#10910) #10915
base: develop
Are you sure you want to change the base?
Conversation
6baf5c5
to
e209465
Compare
e209465
to
695b550
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit rusty with KeePassXC code but added some comments. Otherwise I think it'll do the correct thing!
// Read public headers | ||
QString error; | ||
QScopedPointer<Database> db(new Database()); | ||
return db->open(filePath, nullptr, &error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could inline this since you have only a single call for it and use the error string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't sure if I should use the error string, as it can be quite long and may not fit in the message box. I added the error anyway, as it is better to have it rather than leave the user in the dark.
I did not inline the method though, as I prefer having a named method, rather than calling Database::open
with a nullptr
as second parameter, which implies reading the headers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we are repeating this pattern we should introduce a Database::readHeaders
function that takes care of the particulars.
} | ||
|
||
if (!hasValidPublicHeaders(result.filePath)) { | ||
m_ui->messageWidget->showMessage(tr("Download finished, but file failed KeePass header check. File is not a " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could use the actual error from database open here. "KeePass header check" is quite a technical error message as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have adapted the error message
0378725
to
7753774
Compare
LGTM, I haven't yet tested this but the code look fine |
Verify downloaded file.
Context: #10910
Screenshots
Testing strategy
Test a command that downloads a random file that is not a KeePass database.
Type of change