Optimize CaseConflictRecords search in local DB during the sync.

Signed-off-by: alex-z <blackslayer4@gmail.com>
This commit is contained in:
alex-z 2023-09-21 15:49:23 +02:00 committed by Matthieu Gallien
parent b3f3cff16f
commit fde7933585
3 changed files with 15 additions and 1 deletions

View file

@ -824,6 +824,14 @@ bool SyncJournalDb::updateMetadataTableStructure()
addColumn(QStringLiteral("lockTime"), QStringLiteral("INTEGER"));
addColumn(QStringLiteral("lockTimeout"), QStringLiteral("INTEGER"));
SqlQuery query(_db);
query.prepare("CREATE INDEX IF NOT EXISTS caseconflicts_basePath ON caseconflicts(basePath);");
if (!query.exec()) {
sqlFail(QStringLiteral("caseconflictsTableStructure: create index basePath"), query);
return re = false;
}
commitInternal(QStringLiteral("update database structure: add basePath index"));
return re;
}

View file

@ -76,6 +76,8 @@ void ProcessDirectoryJob::start()
{
qCInfo(lcDisco) << "STARTING" << _currentFolder._server << _queryServer << _currentFolder._local << _queryLocal;
_discoveryData->_noCaseConflictRecordsInDb = _discoveryData->_statedb->caseClashConflictRecordPaths().isEmpty();
if (_queryServer == NormalQuery) {
_serverJob = startAsyncServerQuery();
} else {
@ -799,7 +801,9 @@ void ProcessDirectoryJob::processFileAnalyzeRemoteInfo(const SyncFileItemPtr &it
item->_modtime = serverEntry.modtime;
item->_size = serverEntry.size;
const auto conflictRecord = _discoveryData->_statedb->caseConflictRecordByBasePath(item->_file);
const auto conflictRecord = _discoveryData->_noCaseConflictRecordsInDb
? ConflictRecord{} :
_discoveryData->_statedb->caseConflictRecordByBasePath(item->_file);
if (conflictRecord.isValid() && QString::fromUtf8(conflictRecord.path).contains(QStringLiteral("(case clash from"))) {
qCInfo(lcDisco) << "should ignore" << item->_file << "has already a case clash conflict record" << conflictRecord.path;

View file

@ -321,6 +321,8 @@ public:
bool _hasUploadErrorItems = false;
bool _hasDownloadRemovedItems = false;
bool _noCaseConflictRecordsInDb = false;
signals:
void fatalError(const QString &errorString, const OCC::ErrorCategory errorCategory);
void itemDiscovered(const OCC::SyncFileItemPtr &item);