mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-05 09:33:25 -08:00
* [Settings] Back up the settings folder before migrating The per-file settings migration only preserved global.ini, as global.ini.old. Everything else the migrations write was overwritten in place with no way back: the legacy migration and the 17 per-domain migrateXxxSettings functions all write straight into the per-domain .ini files, so any of them that got a key mapping wrong silently replaced a working file. The re-migration path is the sharpest case, because migrateSettingsFromGlobalIni() runs again whenever an older build wrote non-sentinel keys back into global.ini, and those values then land on top of per-domain files the user had already edited. Snapshot the whole settings folder before either migration runs, into a timestamped sibling settings-backup-<yyyyMMdd-HHmmss>. A sibling rather than a child, so a backup is never copied into the next backup and the "Open Settings Folder" action keeps showing only live files. Keep every snapshot; settings files are kilobytes, so growth is not a concern. SettingsMigration::isMigrationPending() gates the copy so a normal start creates nothing. It reuses the same condition migrateSettingsFromGlobalIni() uses to decide whether it has work, factored into a shared helper so the two cannot drift, and it ignores the legacy migration on an empty profile where that migration only writes its sentinel. The backup itself skips a folder whose files are all empty, which covers a fresh profile whose global.ini was created but never written. A failed copy logs a warning and returns an empty path rather than aborting the migration, since a full disk or an unwritable data folder must not leave the client unable to start. global.ini.old still works as the single-file escape hatch. Document the folder layout, the automatic backups, and the fact that migrations only run forwards, so users know to copy the settings folder before downgrading to a version that cannot read the per-group files. * [Client] Match the desktop file name case for the portal app ID QGuiApplication::setDesktopFileName() was given "Cockatrice"/"Oracle" while the installed desktop entries are cockatrice.desktop and oracle.desktop. Linux paths are case-sensitive, so xdg-desktop-portal failed the app-info lookup for "Cockatrice" and Qt warned on every QDesktopServices call that it could not register with the host portal. The same string becomes the xdg-shell appId, so the window icon lookup failed on Wayland for the same reason. --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
26 lines
916 B
C++
26 lines
916 B
C++
#ifndef SETTINGS_MIGRATION_H
|
|
#define SETTINGS_MIGRATION_H
|
|
|
|
#include <QString>
|
|
|
|
class SettingsMigration
|
|
{
|
|
public:
|
|
static bool migrateSettingsFromGlobalIni(const QString &settingsPath);
|
|
static bool migrateLegacySettings(const QString &settingsPath);
|
|
|
|
/**
|
|
* Returns true when at least one of the two migrations would still do work, i.e. when a
|
|
* backup of the settings directory is worth taking before they run.
|
|
*/
|
|
static bool isMigrationPending(const QString &settingsPath);
|
|
|
|
/**
|
|
* Copies the whole settings directory to a timestamped sibling folder, so a migration that
|
|
* overwrites per-domain files can be undone by hand. Returns the backup path, or an empty
|
|
* string when there was nothing to back up or the copy failed. Never aborts the migration.
|
|
*/
|
|
static QString backupSettingsDirectory(const QString &settingsPath);
|
|
};
|
|
|
|
#endif // SETTINGS_MIGRATION_H
|