mirror of
https://github.com/nextcloud/desktop.git
synced 2025-10-26 11:17:43 +00:00
chore(db): do not create db records with invalid mtime
only add a Q_ASSERT for debug builds Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
This commit is contained in:
parent
f78ad0e0d5
commit
b050fe7481
@ -1015,6 +1015,11 @@ Result<void, QString> 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 + "/";
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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));
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user