Skip to content

Commit

Permalink
Optimize CaseConflictRecords search in local DB during the sync.
Browse files Browse the repository at this point in the history
Signed-off-by: alex-z <[email protected]>
  • Loading branch information
allexzander authored and mgallien committed Sep 25, 2023
1 parent b3f3cff commit fde7933
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/common/syncjournaldb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
6 changes: 5 additions & 1 deletion src/libsync/discovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;

Expand Down
2 changes: 2 additions & 0 deletions src/libsync/discoveryphase.h
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,8 @@ class DiscoveryPhase : public QObject
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);
Expand Down

0 comments on commit fde7933

Please sign in to comment.