mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-08 11:03:25 -08:00
Address review findings
This commit is contained in:
parent
80ca738541
commit
2992bfdac1
5 changed files with 29 additions and 17 deletions
|
|
@ -858,6 +858,16 @@ void DeckSyncManager::queueConflict(const QString &relativePath,
|
|||
.guid = serverGuid,
|
||||
.hash = serverHash,
|
||||
.lastModifiedSecs = serverLastModifiedSecs};
|
||||
if (autoRun) {
|
||||
// An auto run has no user in front of it: opening the modal conflict
|
||||
// dialog from a timer or a file-watcher event would pop up mid-game.
|
||||
// Leave the path untouched so the next manual sync classifies it again
|
||||
// and asks — and skip the server fetch, which would only be discarded
|
||||
// and repeated on every poll.
|
||||
++conflictCount;
|
||||
++skippedCount;
|
||||
return;
|
||||
}
|
||||
pendingConflicts.insert(relativePath, ctx);
|
||||
conflictPaths.insert(relativePath);
|
||||
applyDownload(relativePath, deckId, serverGuid, serverHash, serverLastModifiedSecs);
|
||||
|
|
@ -865,17 +875,10 @@ void DeckSyncManager::queueConflict(const QString &relativePath,
|
|||
|
||||
void DeckSyncManager::handleConflictDownload(const QString &relativePath, const QString &serverDeckString)
|
||||
{
|
||||
// Only a manual run fetches a conflicting server copy, so this point is
|
||||
// never reached with autoRun set: queueConflict() records the conflict and
|
||||
// leaves the path alone instead.
|
||||
const ConflictDownload ctx = pendingConflicts.take(relativePath);
|
||||
if (autoRun) {
|
||||
// An auto run has no user in front of it: opening the modal conflict
|
||||
// dialog from a timer or a file-watcher event would pop up mid-game.
|
||||
// Leave the path untouched so the next manual sync classifies it again
|
||||
// and asks.
|
||||
++conflictCount;
|
||||
++skippedCount;
|
||||
processNext();
|
||||
return;
|
||||
}
|
||||
if (sessionDefault == DeckSyncConflictKeepMine) {
|
||||
applyUpload(relativePath, ctx.serverPath, ctx.deckId, ctx.guid);
|
||||
processNext();
|
||||
|
|
@ -1349,7 +1352,8 @@ void DeckSyncManager::onDeleteFinished(const Response &response,
|
|||
}
|
||||
}
|
||||
// Both outcomes converge the record: pushed deletes and server-side
|
||||
// deletes (already tombstoned, answering NameNotFound) are done.
|
||||
// deletes (already tombstoned, answering NameNotFound) are done. Either
|
||||
// way the server tree the client is showing is stale, so both count.
|
||||
if (response.response_code() == Response::RespOk || response.response_code() == Response::RespNameNotFound) {
|
||||
DeckSyncSidecar sidecar(sidecarPath);
|
||||
sidecar.load();
|
||||
|
|
@ -1418,10 +1422,9 @@ void DeckSyncManager::finishSync()
|
|||
if (!summary.note.isEmpty()) {
|
||||
message += QStringLiteral(" ") + summary.note;
|
||||
}
|
||||
// The conflict count travels in the summary: a statusMessage here would be
|
||||
// overwritten by the syncFinished() summary the tab renders next.
|
||||
emit statusMessage(message);
|
||||
if (conflictCount > 0) {
|
||||
emit statusMessage(tr("%1 conflicting decks skipped. Press Sync now to resolve them.").arg(conflictCount));
|
||||
}
|
||||
emit syncFinished(summary, QString());
|
||||
}
|
||||
|
||||
|
|
@ -1433,6 +1436,7 @@ DeckSyncManager::SyncSummary DeckSyncManager::currentSummary() const
|
|||
.removed = removedCount,
|
||||
.unchanged = unchangedCount,
|
||||
.skipped = skippedCount,
|
||||
.conflicts = conflictCount,
|
||||
.note = syncNote,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,6 +70,8 @@ public:
|
|||
int removed = 0; ///< Decks deleted on the server, or locally to mirror a server delete.
|
||||
int unchanged = 0;
|
||||
int skipped = 0;
|
||||
/** @brief Both-sides-changed decks left untouched for a manual verdict. */
|
||||
int conflicts = 0;
|
||||
QString note; ///< Non-error caveat about this run, empty when there is none.
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ public:
|
|||
/// keeps it out of sync, and the first-sync verdicts narrow it to one
|
||||
/// direction. An unrecognised value falls back to the two-way sync.
|
||||
QString mode = MODE_LINKED;
|
||||
qint64 lastSyncSecs = 0; ///< Last completed sync, seconds since epoch; 0 means never.
|
||||
qint64 lastSyncSecs = 0; ///< Last completed sync, seconds since epoch; 0 means never.
|
||||
|
||||
explicit DeckSyncSidecar(const QString &_filePath);
|
||||
|
||||
|
|
|
|||
|
|
@ -668,7 +668,9 @@ void TabDeckStorage::onSyncFinished(const SyncSummary &summary, const QString &e
|
|||
lastSyncSummary = summary;
|
||||
}
|
||||
renderSyncStatus();
|
||||
if (error.isEmpty()) {
|
||||
// An idle poll changes nothing: refreshing the tree there would send a
|
||||
// fresh Command_DeckList every interval for every connected client.
|
||||
if (error.isEmpty() && summary.uploaded + summary.downloaded + summary.removed > 0) {
|
||||
serverDirView->refreshTree();
|
||||
}
|
||||
}
|
||||
|
|
@ -689,6 +691,10 @@ void TabDeckStorage::renderSyncStatus()
|
|||
.arg(lastSyncSummary.removed)
|
||||
.arg(lastSyncSummary.unchanged)
|
||||
.arg(lastSyncSummary.skipped);
|
||||
if (lastSyncSummary.conflicts > 0) {
|
||||
text += QStringLiteral(" ") + tr("%n conflicting deck(s) skipped. Press Sync now to resolve them.", "",
|
||||
lastSyncSummary.conflicts);
|
||||
}
|
||||
if (!lastSyncSummary.note.isEmpty()) {
|
||||
text += QStringLiteral("\n") + lastSyncSummary.note;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue