Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize CaseConflictRecords search in local DB during the sync. #6083

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
@@ -1,4 +1,4 @@
/*

Check notice on line 1 in src/libsync/discovery.cpp

View workflow job for this annotation

GitHub Actions / build

Run clang-format on src/libsync/discovery.cpp

File src/libsync/discovery.cpp (lines 804, 805): Code does not conform to Custom style guidelines.
* Copyright (C) by Olivier Goffart <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -76,6 +76,8 @@
{
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 @@
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
Loading