diff --git a/src/common/syncjournaldb.cpp b/src/common/syncjournaldb.cpp index 5b867fac33..a846a82275 100644 --- a/src/common/syncjournaldb.cpp +++ b/src/common/syncjournaldb.cpp @@ -1015,6 +1015,11 @@ Result SyncJournalDb::setFileRecord(const SyncJournalFileRecord & SyncJournalFileRecord record = _record; QMutexLocker locker(&_mutex); + Q_ASSERT(record._modtime > 0); + if (record._modtime <= 0) { + qCCritical(lcDb) << "invalid modification time"; + } + if (!_etagStorageFilter.isEmpty()) { // If we are a directory that should not be read from db next time, don't write the etag QByteArray prefix = record._path + "/"; diff --git a/test/testfolderman.cpp b/test/testfolderman.cpp index 284b9d2aae..2469e0022f 100644 --- a/test/testfolderman.cpp +++ b/test/testfolderman.cpp @@ -137,6 +137,7 @@ private slots: // the server, let's just manually set the encryption bool in the folder journal SyncJournalFileRecord rec; QVERIFY(folder->journalDb()->getFileRecord(QStringLiteral("encrypted"), &rec)); + rec._modtime = QDateTime::currentSecsSinceEpoch(); rec._e2eEncryptionStatus = SyncJournalFileRecord::EncryptionStatus::EncryptedMigratedV2_0; rec._path = QStringLiteral("encrypted").toUtf8(); rec._type = CSyncEnums::ItemTypeDirectory; diff --git a/test/testsyncjournaldb.cpp b/test/testsyncjournaldb.cpp index 424b439af3..1e71e25ff7 100644 --- a/test/testsyncjournaldb.cpp +++ b/test/testsyncjournaldb.cpp @@ -263,6 +263,7 @@ private slots: auto initialEtag = QByteArray("etag"); auto makeEntry = [&](const QByteArray &path, ItemType type) { SyncJournalFileRecord record; + record._modtime = QDateTime::currentSecsSinceEpoch(); record._path = path; record._type = type; record._etag = initialEtag; @@ -329,6 +330,7 @@ private slots: SyncJournalFileRecord record; record._path = path; record._remotePerm = RemotePermissions::fromDbValue("RW"); + record._modtime = QDateTime::currentSecsSinceEpoch(); QVERIFY(_db.setFileRecord(record)); };