mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-01-27 23:07:11 -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 "FileWatcher.h"
|
||||||
|
|
||||||
|
#include "core/AsyncTask.h"
|
||||||
#include "core/Clock.h"
|
#include "core/Clock.h"
|
||||||
|
|
||||||
#include <QCryptographicHash>
|
#include <QCryptographicHash>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
|
||||||
@ -134,6 +136,7 @@ void FileWatcher::checkFileChecksum()
|
|||||||
|
|
||||||
QByteArray FileWatcher::calculateChecksum()
|
QByteArray FileWatcher::calculateChecksum()
|
||||||
{
|
{
|
||||||
|
return AsyncTask::runAndWaitForFuture([this]() -> QByteArray {
|
||||||
QFile file(m_filePath);
|
QFile file(m_filePath);
|
||||||
if (file.open(QFile::ReadOnly)) {
|
if (file.open(QFile::ReadOnly)) {
|
||||||
QCryptographicHash hash(QCryptographicHash::Sha256);
|
QCryptographicHash hash(QCryptographicHash::Sha256);
|
||||||
@ -145,6 +148,7 @@ QByteArray FileWatcher::calculateChecksum()
|
|||||||
return hash.result();
|
return hash.result();
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
BulkFileWatcher::BulkFileWatcher(QObject* parent)
|
BulkFileWatcher::BulkFileWatcher(QObject* parent)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user