Fix remaining review threads on the conflict classification

- Remove the duplicated download loop and the stray '<' plus extra brace
  that left the head unbuildable.
- Skip the fallback upload under DownloadMode so a local-only deck is not
  pushed when the user asked for downloads only.
- Treat a server row without a hash as unknown rather than changed, so
  pre-migration decks are not re-downloaded on every sync.
This commit is contained in:
Lukas Brübach 2026-11-01 05:08:27 +01:00 • committed by Lukas Brübach
parent cc68893d23
commit ae4d40e1eb
2 changed files with 9 additions and 7 deletions

View file

@ -261,7 +261,7 @@ void DeckSyncManager::cancelFirstSync()
failSync(tr("Sync cancelled."));
}
void DeckSyncManager::classify(const QMap<QString, ServerFile> &serverFiles)
void DeckSyncManager::classify(const QMap<int, ServerFile> &serverFiles)
{
emit statusMessage(tr("Comparing %1 local and %2 server decks...").arg(localFiles.size()).arg(serverFiles.size()));
@ -374,20 +374,22 @@ void DeckSyncManager::classify(const QMap<QString, ServerFile> &serverFiles)
}
const DeckSyncRecord baseRecord = sidecar.get(it.key());
const bool localChanged = baseRecord.baseHash.isEmpty() || baseRecord.baseHash != it.value().hash;
const bool serverChanged = baseRecord.baseHash.isEmpty() || baseRecord.baseHash != serverIt.value().hash;
// A server row without a hash predates sync: treat it as unknown rather than changed,
// otherwise every sync re-downloads the deck.
const bool serverChanged =
!server.hash.isEmpty() && (baseRecord.baseHash.isEmpty() || baseRecord.baseHash != server.hash);
if (localChanged && !serverChanged) {
if (syncMode == DeckSyncMode::DownloadOnly) {
continue;
}
applyUpload(it.key(), serverPath, serverIt.value().id, serverIt.value().guid);
applyUpload(it.key(), server.path, server.id, server.guid);
continue;
}
if (!localChanged && serverChanged) {
if (syncMode == DeckSyncMode::UploadOnly) {
continue;
}
applyDownload(it.key(), serverIt.value().id, serverIt.value().guid, serverIt.value().hash,
serverIt.value().lastModifiedSecs);
applyDownload(it.key(), server.id, server.guid, server.hash, server.lastModifiedSecs);
continue;
}
const qint64 localSecs = it.value().modified.toSecsSinceEpoch();

View file

@ -170,7 +170,7 @@ private:
void sendDelete(const QString &relativePath, int deckId);
void snapshotLocalFile(const QString &relativePath, const QString &guid);
QString readBaseSnapshot(const QString &guid) const;
void classify(const QMap<QString, ServerFile> &serverFiles);
void classify(const QMap<int, ServerFile> &serverFiles);
void queueConflict(const QString &relativePath,
const QString &serverPath,
int deckId,
@ -208,7 +208,7 @@ private:
QList<QString> pendingDeletes;
QSet<QString> conflictPaths;
QMap<QString, ConflictDownload> pendingConflicts;
QMap<QString, ServerFile> stashedServerFiles;
QMap<int, ServerFile> stashedServerFiles;
ActiveConflict activeConflict;
DeckSyncMode syncMode = DeckSyncMode::TwoWay;
int conflictDefault = DeckSyncConflictAsk;