Cockatrice 2026-10-19-Development-3.1.2-beta.2
A virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
user_data_backup.h File Reference

Best-effort safety copies of user data that lives inside the install directory. More...

#include <QString>
#include <QStringList>
Include dependency graph for user_data_backup.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  UserDataBackup

Functions

bool UserDataBackup::copyDirectoryRecursively (const QString &sourceDir, const QString &destDir)
 Recursively copies sourceDir into destDir, creating it as needed.
bool UserDataBackup::createBackupSessionDir (const QString &backupRoot, QString *sessionDirOut)
 Creates a fresh timestamped session directory under backupRoot.
bool UserDataBackup::backupAtRiskPaths (const QStringList &sourcePaths, const QString &backupRoot, QStringList *backupLocationsOut, QString *sessionDirOut=nullptr)
 Copies several at-risk paths into a single timestamped session directory.
qint64 UserDataBackup::estimateBackupSize (const QStringList &sourcePaths, qint64 capBytes=MAX_AUTO_BACKUP_BYTES)
 Estimates the total bytes that backing up sourcePaths would copy.
QString UserDataBackup::defaultBackupRoot ()
 Default backup root guaranteed to live outside the install directory.
QStringList UserDataBackup::listBackupSessions (const QString &backupRoot)
 Lists existing backup session directories under backupRoot, newest first.
QString UserDataBackup::findRecentUsableBackupSession (const QString &backupRoot, const QStringList &sourcePaths, int maxAgeHours=24)
 Returns the newest session that is non-empty, complete and covering sourcePaths, or empty.
QString UserDataBackup::findRecentCoveringBackupSession (const QString &backupRoot, const QStringList &sourcePaths, int maxAgeHours=24)
 Returns the newest non-empty session covering sourcePaths, regardless of completeness.
bool UserDataBackup::isBackupSessionComplete (const QString &sessionDir)
 Reports whether sessionDir holds a complete backup.
void UserDataBackup::pruneOldBackupSessions (const QString &backupRoot, int keepCount=5)
 Deletes oldest sessions keeping only the newest keepCount ones. Empty sessions are junk from failed attempts and are always removed, so they can never evict a good session from the kept set.
QStringList UserDataBackup::listSessionBackupLocations (const QString &sessionDir)
 Lists the backup targets inside an existing session directory.
bool UserDataBackup::sessionCoversSources (const QString &sessionDir, const QStringList &sourcePaths)
 Reports whether sessionDir was recorded as covering all of sourcePaths.

Variables

constexpr qint64 UserDataBackup::MAX_AUTO_BACKUP_BYTES = 200LL * 1024 * 1024
 Above this total, the client skips the automatic startup backup and asks for a manual copy. Kept small on purpose: the copy runs synchronously on the UI thread at startup.

Detailed Description

Best-effort safety copies of user data that lives inside the install directory.

Background: Windows uninstallers shipped in 3.1.0/3.1.1 ran a blanket "RMDir /r $INSTDIR". For a portable install that deletes $INSTDIR\data (decks, settings, pictures) along with the payload, and for a normal install it deletes anything the user pointed into $INSTDIR. The fixed uninstaller preserves foreign files, but the destructive one is already on disk on affected machines, so the client keeps a safety copy outside the install directory before warning the user. Detection of at-risk paths lives in PathsSettings::pathsInsideDir; this helper only copies.