mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-01-13 08:19:50 -05:00
Perform file hash checks asynchronously (#3815)
This commit is contained in:
parent
7ba9fcc0e5
commit
d3978980d2
@ -18,7 +18,9 @@
|
||||
|
||||
#include "FileWatcher.h"
|
||||
|
||||
#include "core/AsyncTask.h"
|
||||
#include "core/Clock.h"
|
||||
|
||||
#include <QCryptographicHash>
|
||||
#include <QFileInfo>
|
||||
|
||||
@ -134,17 +136,19 @@ void FileWatcher::checkFileChecksum()
|
||||
|
||||
QByteArray FileWatcher::calculateChecksum()
|
||||
{
|
||||
QFile file(m_filePath);
|
||||
if (file.open(QFile::ReadOnly)) {
|
||||
QCryptographicHash hash(QCryptographicHash::Sha256);
|
||||
if (m_fileChecksumSizeBytes > 0) {
|
||||
hash.addData(file.read(m_fileChecksumSizeBytes));
|
||||
} else {
|
||||
hash.addData(&file);
|
||||
return AsyncTask::runAndWaitForFuture([this]() -> QByteArray {
|
||||
QFile file(m_filePath);
|
||||
if (file.open(QFile::ReadOnly)) {
|
||||
QCryptographicHash hash(QCryptographicHash::Sha256);
|
||||
if (m_fileChecksumSizeBytes > 0) {
|
||||
hash.addData(file.read(m_fileChecksumSizeBytes));
|
||||
} else {
|
||||
hash.addData(&file);
|
||||
}
|
||||
return hash.result();
|
||||
}
|
||||
return hash.result();
|
||||
}
|
||||
return {};
|
||||
return {};
|
||||
});
|
||||
}
|
||||
|
||||
BulkFileWatcher::BulkFileWatcher(QObject* parent)
|
||||
|
Loading…
Reference in New Issue
Block a user