mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-06 10:03:26 -08:00
[DeckSync] Address tombstone review: remote deletes, revival and purge clock
- Treat a record whose server row is gone as a remote delete only when the local file still matches the sidecar's base hash. An edit made after the remote delete is newer than the delete, so it uploads and revives the row instead of being removed. - Revive a tombstone with the same user and guid in cmdDeckUpload instead of inserting a second row next to it, so the deck keeps its id and version history and the promise in servatrice.ini.example holds. - Run tombstone purging on its own clock, driven by the new [deck_sync] purge_interval option, so disabling share cleanup no longer disables purging silently. - Write the base snapshot through QSaveFile and log a failed commit, so a crash or a full disk cannot leave a truncated base for DeckDiff::merge().
This commit is contained in:
parent
157e63b179
commit
de3468cc33
5 changed files with 112 additions and 34 deletions
|
|
@ -622,7 +622,6 @@ bool Servatrice::initServer()
|
|||
|
||||
deckShareCleanupClock = new QTimer(this);
|
||||
connect(deckShareCleanupClock, SIGNAL(timeout()), this, SLOT(cleanupExpiredDeckShares()));
|
||||
connect(deckShareCleanupClock, SIGNAL(timeout()), this, SLOT(purgeDeckTombstones()));
|
||||
const int deckShareCleanupInterval = getDeckShareCleanupInterval();
|
||||
if (deckShareCleanupInterval > 0) {
|
||||
qDebug() << "Starting deck share cleanup clock, interval" << deckShareCleanupInterval << "ms";
|
||||
|
|
@ -633,6 +632,16 @@ bool Servatrice::initServer()
|
|||
connect(legacyBackupSweepClock, &QTimer::timeout, this, &Servatrice::sweepLegacyBackups);
|
||||
legacyBackupSweepClock->start(kLegacyBackupSweepIntervalMs);
|
||||
|
||||
// Tombstone purging runs on its own clock: turning share cleanup off must not
|
||||
// silently disable it as well.
|
||||
deckTombstoneClock = new QTimer(this);
|
||||
connect(deckTombstoneClock, SIGNAL(timeout()), this, SLOT(purgeDeckTombstones()));
|
||||
const int deckSyncPurgeInterval = getDeckSyncPurgeInterval();
|
||||
if (deckSyncPurgeInterval > 0) {
|
||||
qDebug() << "Starting deck tombstone purge clock, interval" << deckSyncPurgeInterval << "ms";
|
||||
deckTombstoneClock->start(deckSyncPurgeInterval);
|
||||
}
|
||||
|
||||
// SOCKET SERVER
|
||||
if (getNumberOfTCPPools() > 0) {
|
||||
gameServer =
|
||||
|
|
@ -1412,6 +1421,12 @@ int Servatrice::getDeckSyncTombstoneDays() const
|
|||
return qMax(0, settingsCache->value("deck_sync/tombstone_days", 30).toInt());
|
||||
}
|
||||
|
||||
int Servatrice::getDeckSyncPurgeInterval() const
|
||||
{
|
||||
// default: every 60 minutes, independent of deck_share/cleanup_interval
|
||||
return qMax(0, settingsCache->value("deck_sync/purge_interval", 60).toInt()) * 60000;
|
||||
}
|
||||
|
||||
int Servatrice::getNumberOfTCPPools() const
|
||||
{
|
||||
return settingsCache->value("server/number_pools", 1).toInt();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue