Significantly reduce impact of FileWatcher hashing (#3724)

* Fix #3699

Reduce file watch hashing of open database files from every second to every 30 seconds. Additionally, only hash the first 1024 bytes of the database file. This is valid since most of the header and the entire encrypted portion are changed significantly on every save.
This commit is contained in:
Jonathan White 2019-10-30 06:40:56 -04:00 committed by Janek Bevendorff
parent 178bea6bbc
commit 36e14157be
3 changed files with 17 additions and 7 deletions

View file

@ -158,7 +158,7 @@ bool Database::open(const QString& filePath, QSharedPointer<const CompositeKey>
m_initialized = true;
emit databaseOpened();
m_fileWatcher->start(canonicalFilePath());
m_fileWatcher->start(canonicalFilePath(), 30, 1);
setEmitModified(true);
return true;
@ -234,7 +234,7 @@ bool Database::saveAs(const QString& filePath, QString* error, bool atomic, bool
bool ok = performSave(canonicalFilePath, error, atomic, backup);
if (ok) {
setFilePath(filePath);
m_fileWatcher->start(canonicalFilePath);
m_fileWatcher->start(canonicalFilePath, 30, 1);
} else {
// Saving failed, don't rewatch file since it does not represent our database
markAsModified();