From 4278a320e46042c47de929500b559ed079dc20b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Mon, 6 Dec 2021 20:12:02 +0100 Subject: [PATCH] Fix skin setting resetting every launch The reason this was happening was an unfortunate oversight in the migration logic. The code that was attempting to parse the skin settings as `int` was firing regardless of whether a skin migration from EF to realm had already occurred. If it had occurred, the skin setting would contain a GUID rather than an integer, and therefore fail to parse, and therefore implicitly fallback to a EF skin ID of 0 which would be the default skin. Fix by not running the setting migrating logic at all when there are no EF skins to migrate. --- osu.Game/Database/EFToRealmMigrator.cs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/osu.Game/Database/EFToRealmMigrator.cs b/osu.Game/Database/EFToRealmMigrator.cs index 3790dc8ae9..b79a982460 100644 --- a/osu.Game/Database/EFToRealmMigrator.cs +++ b/osu.Game/Database/EFToRealmMigrator.cs @@ -35,6 +35,16 @@ namespace osu.Game.Database private void migrateSkins(DatabaseWriteUsage db) { + // can be removed 20220530. + var existingSkins = db.Context.SkinInfo + .Include(s => s.Files) + .ThenInclude(f => f.FileInfo) + .ToList(); + + // previous entries in EF are removed post migration. + if (!existingSkins.Any()) + return; + var userSkinChoice = config.GetBindable(OsuSetting.Skin); int.TryParse(userSkinChoice.Value, out int userSkinInt); @@ -49,16 +59,6 @@ namespace osu.Game.Database break; } - // migrate ruleset settings. can be removed 20220530. - var existingSkins = db.Context.SkinInfo - .Include(s => s.Files) - .ThenInclude(f => f.FileInfo) - .ToList(); - - // previous entries in EF are removed post migration. - if (!existingSkins.Any()) - return; - using (var realm = realmContextFactory.CreateContext()) using (var transaction = realm.BeginWrite()) {