Fix ZeldaZach review for PR 7496: deck path in ctor, server-time baseline, single-query sync check

This commit is contained in:
Lukas Brübach 2026-10-13 07:21:42 +02:00
parent e0d5d156f2
commit 8b85eafcb1
6 changed files with 30 additions and 41 deletions

View file

@ -274,11 +274,9 @@ void DeckSyncManager::syncNow()
localFiles.insert(relativePath, file);
}
if (!firstSyncRun && sidecar.lastSyncSecs > 0) {
sendSyncCheck(sidecar.lastSyncSecs);
return;
}
fetchFullList();
// Always ask the server first: its server_time becomes the sync baseline,
// so uploads racing the DeckList response cannot fall outside the window.
sendSyncCheck(sidecar.lastSyncSecs);
}
void DeckSyncManager::fetchFullList()
@ -309,6 +307,9 @@ void DeckSyncManager::onCheckFinished(const Response &response, const CommandCon
return;
}
const Response_DeckSyncStatus &status = response.GetExtension(Response_DeckSyncStatus::ext);
if (status.has_server_time()) {
pendingServerTime = static_cast<qint64>(status.server_time());
}
DeckSyncSidecar sidecar(sidecarPath);
if (!sidecar.load()) {
fetchFullList();

View file

@ -261,6 +261,13 @@ TabDeckStorage::TabDeckStorage(TabSupervisor *_tabSupervisor,
syncManager = new DeckSyncManager(this);
syncManager->setClient(client);
syncManager->setDeckPath(SettingsCache::instance().paths().getDeckPath());
connect(&SettingsCache::instance().paths(), &PathsSettings::deckPathChanged, this, [this] {
const QString deckPath = SettingsCache::instance().paths().getDeckPath();
localDirModel->setRootPath(deckPath);
localDirView->setRootIndex(localDirModel->index(localDirModel->rootPath(), 0));
syncManager->setDeckPath(deckPath);
});
syncManager->setColorIdentityProvider(
[](const DeckList &deck) { return getDeckColorIdentity(deck, CardDatabaseManager::query()); });
syncManager->setConflictDefault(SettingsCache::instance().deckSync().getConflictDefault());