mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-05 01:23:24 -08:00
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:
parent
9e4d734373
commit
dcccb0f332
2 changed files with 9 additions and 7 deletions
|
|
@ -261,7 +261,7 @@ void DeckSyncManager::cancelFirstSync()
|
||||||
failSync(tr("Sync cancelled."));
|
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()));
|
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 DeckSyncRecord baseRecord = sidecar.get(it.key());
|
||||||
const bool localChanged = baseRecord.baseHash.isEmpty() || baseRecord.baseHash != it.value().hash;
|
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 (localChanged && !serverChanged) {
|
||||||
if (syncMode == DeckSyncMode::DownloadOnly) {
|
if (syncMode == DeckSyncMode::DownloadOnly) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
applyUpload(it.key(), serverPath, serverIt.value().id, serverIt.value().guid);
|
applyUpload(it.key(), server.path, server.id, server.guid);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!localChanged && serverChanged) {
|
if (!localChanged && serverChanged) {
|
||||||
if (syncMode == DeckSyncMode::UploadOnly) {
|
if (syncMode == DeckSyncMode::UploadOnly) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
applyDownload(it.key(), serverIt.value().id, serverIt.value().guid, serverIt.value().hash,
|
applyDownload(it.key(), server.id, server.guid, server.hash, server.lastModifiedSecs);
|
||||||
serverIt.value().lastModifiedSecs);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const qint64 localSecs = it.value().modified.toSecsSinceEpoch();
|
const qint64 localSecs = it.value().modified.toSecsSinceEpoch();
|
||||||
|
|
|
||||||
|
|
@ -170,7 +170,7 @@ private:
|
||||||
void sendDelete(const QString &relativePath, int deckId);
|
void sendDelete(const QString &relativePath, int deckId);
|
||||||
void snapshotLocalFile(const QString &relativePath, const QString &guid);
|
void snapshotLocalFile(const QString &relativePath, const QString &guid);
|
||||||
QString readBaseSnapshot(const QString &guid) const;
|
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,
|
void queueConflict(const QString &relativePath,
|
||||||
const QString &serverPath,
|
const QString &serverPath,
|
||||||
int deckId,
|
int deckId,
|
||||||
|
|
@ -208,7 +208,7 @@ private:
|
||||||
QList<QString> pendingDeletes;
|
QList<QString> pendingDeletes;
|
||||||
QSet<QString> conflictPaths;
|
QSet<QString> conflictPaths;
|
||||||
QMap<QString, ConflictDownload> pendingConflicts;
|
QMap<QString, ConflictDownload> pendingConflicts;
|
||||||
QMap<QString, ServerFile> stashedServerFiles;
|
QMap<int, ServerFile> stashedServerFiles;
|
||||||
ActiveConflict activeConflict;
|
ActiveConflict activeConflict;
|
||||||
DeckSyncMode syncMode = DeckSyncMode::TwoWay;
|
DeckSyncMode syncMode = DeckSyncMode::TwoWay;
|
||||||
int conflictDefault = DeckSyncConflictAsk;
|
int conflictDefault = DeckSyncConflictAsk;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue