mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-08-20 03:58:10 -04:00
Perform file hash checks asynchronously (#3815)
This commit is contained in:
parent
7ba9fcc0e5
commit
d3978980d2
1 changed files with 14 additions and 10 deletions
|
@ -18,7 +18,9 @@
|
||||||
|
|
||||||
#include "FileWatcher.h"
|
#include "FileWatcher.h"
|
||||||
|
|
||||||
|
#include "core/AsyncTask.h"
|
||||||
#include "core/Clock.h"
|
#include "core/Clock.h"
|
||||||
|
|
||||||
#include <QCryptographicHash>
|
#include <QCryptographicHash>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
|
||||||
|
@ -134,17 +136,19 @@ void FileWatcher::checkFileChecksum()
|
||||||
|
|
||||||
QByteArray FileWatcher::calculateChecksum()
|
QByteArray FileWatcher::calculateChecksum()
|
||||||
{
|
{
|
||||||
QFile file(m_filePath);
|
return AsyncTask::runAndWaitForFuture([this]() -> QByteArray {
|
||||||
if (file.open(QFile::ReadOnly)) {
|
QFile file(m_filePath);
|
||||||
QCryptographicHash hash(QCryptographicHash::Sha256);
|
if (file.open(QFile::ReadOnly)) {
|
||||||
if (m_fileChecksumSizeBytes > 0) {
|
QCryptographicHash hash(QCryptographicHash::Sha256);
|
||||||
hash.addData(file.read(m_fileChecksumSizeBytes));
|
if (m_fileChecksumSizeBytes > 0) {
|
||||||
} else {
|
hash.addData(file.read(m_fileChecksumSizeBytes));
|
||||||
hash.addData(&file);
|
} else {
|
||||||
|
hash.addData(&file);
|
||||||
|
}
|
||||||
|
return hash.result();
|
||||||
}
|
}
|
||||||
return hash.result();
|
return {};
|
||||||
}
|
});
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BulkFileWatcher::BulkFileWatcher(QObject* parent)
|
BulkFileWatcher::BulkFileWatcher(QObject* parent)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue