Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/keepassxreboot/keepassxc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan White <support@dmapps.us>2019-11-09 16:02:34 +0300
committerJanek Bevendorff <janek@jbev.net>2019-11-09 16:02:34 +0300
commitd3978980d2e5b866e6f8b37ed1f69972e7bd6b9a (patch)
tree451c14a22fedab4ae18139558a3127ff3aea5712 /src/core/FileWatcher.cpp
parent7ba9fcc0e5dda352b602785cc4d987e49f241ae4 (diff)
Perform file hash checks asynchronously (#3815)
Diffstat (limited to 'src/core/FileWatcher.cpp')
-rw-r--r--src/core/FileWatcher.cpp24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/core/FileWatcher.cpp b/src/core/FileWatcher.cpp
index 82328832f..0d1def31a 100644
--- a/src/core/FileWatcher.cpp
+++ b/src/core/FileWatcher.cpp
@@ -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)