mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-08 11:03:25 -08:00
[DeckSync] Drop the queued download when a local delete wins
The unmatched-server-rows pass queued a download for every row with no local file, including rows whose sidecar record is being deleted in the same run. The delete ran first, so the download then failed with NameNotFound and the summary reported a clean delete as removed plus skipped. Cancel the pending download for the deleted row id instead; a failed delete keeps it, which preserves the restore-the-file fallback.
This commit is contained in:
parent
885b7f82ae
commit
d0cd13fce7
1 changed files with 8 additions and 0 deletions
|
|
@ -762,8 +762,16 @@ void DeckSyncManager::onDeleteFinished(const Response &response,
|
||||||
if (response.response_code() == Response::RespOk || response.response_code() == Response::RespNameNotFound) {
|
if (response.response_code() == Response::RespOk || response.response_code() == Response::RespNameNotFound) {
|
||||||
DeckSyncSidecar sidecar(sidecarPath);
|
DeckSyncSidecar sidecar(sidecarPath);
|
||||||
sidecar.load();
|
sidecar.load();
|
||||||
|
const int deletedDeckId = sidecar.get(relativePath).remoteId;
|
||||||
sidecar.remove(relativePath);
|
sidecar.remove(relativePath);
|
||||||
sidecar.save();
|
sidecar.save();
|
||||||
|
if (deletedDeckId != -1) {
|
||||||
|
// The unmatched-server-rows pass queued a download for this row before
|
||||||
|
// the delete ran. The delete won, so drop the download instead of
|
||||||
|
// letting it fail with NameNotFound and count as a skipped deck. A
|
||||||
|
// failed delete leaves the download in place as the fallback.
|
||||||
|
pendingDownloads.removeIf([deletedDeckId](const DownloadOp &op) { return op.deckId == deletedDeckId; });
|
||||||
|
}
|
||||||
++removedCount;
|
++removedCount;
|
||||||
} else {
|
} else {
|
||||||
++skippedCount;
|
++skippedCount;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue