mirror of
https://github.com/osukey/osukey.git
synced 2025-05-06 22:27:25 +09:00
Merge pull request #17502 from peppy/m1-migration-information
This commit is contained in:
commit
fefff59b9a
@ -1,10 +1,14 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
#nullable enable
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using osu.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Development;
|
using osu.Framework.Development;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
@ -14,6 +18,7 @@ using osu.Framework.Platform;
|
|||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Models;
|
using osu.Game.Models;
|
||||||
@ -29,8 +34,6 @@ using SharpCompress.Archives.Zip;
|
|||||||
using SharpCompress.Common;
|
using SharpCompress.Common;
|
||||||
using SharpCompress.Writers.Zip;
|
using SharpCompress.Writers.Zip;
|
||||||
|
|
||||||
#nullable enable
|
|
||||||
|
|
||||||
namespace osu.Game.Database
|
namespace osu.Game.Database
|
||||||
{
|
{
|
||||||
internal class EFToRealmMigrator : CompositeDrawable
|
internal class EFToRealmMigrator : CompositeDrawable
|
||||||
@ -57,7 +60,7 @@ namespace osu.Game.Database
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private Storage storage { get; set; } = null!;
|
private Storage storage { get; set; } = null!;
|
||||||
|
|
||||||
private readonly OsuSpriteText currentOperationText;
|
private readonly OsuTextFlowContainer currentOperationText;
|
||||||
|
|
||||||
public EFToRealmMigrator()
|
public EFToRealmMigrator()
|
||||||
{
|
{
|
||||||
@ -99,11 +102,13 @@ namespace osu.Game.Database
|
|||||||
{
|
{
|
||||||
State = { Value = Visibility.Visible }
|
State = { Value = Visibility.Visible }
|
||||||
},
|
},
|
||||||
currentOperationText = new OsuSpriteText
|
currentOperationText = new OsuTextFlowContainer(cp => cp.Font = OsuFont.Default.With(size: 30))
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
Font = OsuFont.Default.With(size: 30)
|
AutoSizeAxes = Axes.Y,
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
TextAnchor = Anchor.TopCentre,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -147,19 +152,34 @@ namespace osu.Game.Database
|
|||||||
log("Migration successful!");
|
log("Migration successful!");
|
||||||
|
|
||||||
if (DebugUtils.IsDebugBuild)
|
if (DebugUtils.IsDebugBuild)
|
||||||
Logger.Log("Your development database has been fully migrated to realm. If you switch back to a pre-realm branch and need your previous database, rename the backup file back to \"client.db\".\n\nNote that doing this can potentially leave your file store in a bad state.", level: LogLevel.Important);
|
{
|
||||||
|
Logger.Log(
|
||||||
|
"Your development database has been fully migrated to realm. If you switch back to a pre-realm branch and need your previous database, rename the backup file back to \"client.db\".\n\nNote that doing this can potentially leave your file store in a bad state.",
|
||||||
|
level: LogLevel.Important);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
log("Migration failed!");
|
log("Migration failed!");
|
||||||
Logger.Log(t.Exception.ToString(), LoggingTarget.Database);
|
Logger.Log(t.Exception.ToString(), LoggingTarget.Database);
|
||||||
|
|
||||||
|
if (RuntimeInfo.OS == RuntimeInfo.Platform.macOS && t.Exception.Flatten().InnerException is TypeInitializationException)
|
||||||
|
{
|
||||||
|
// Not guaranteed to be the only cause of exception, but let's roll with it for now.
|
||||||
|
log("Please download and run the intel version of osu! once\nto allow data migration to complete!");
|
||||||
|
efContextFactory.SetMigrationCompletion();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
notificationOverlay.Post(new SimpleErrorNotification
|
notificationOverlay.Post(new SimpleErrorNotification
|
||||||
{
|
{
|
||||||
Text = "IMPORTANT: During data migration, some of your data could not be successfully migrated. The previous version has been backed up.\n\nFor further assistance, please open a discussion on github and attach your backup files (click to get started).",
|
Text =
|
||||||
|
"IMPORTANT: During data migration, some of your data could not be successfully migrated. The previous version has been backed up.\n\nFor further assistance, please open a discussion on github and attach your backup files (click to get started).",
|
||||||
Activated = () =>
|
Activated = () =>
|
||||||
{
|
{
|
||||||
game.OpenUrlExternally($@"https://github.com/ppy/osu/discussions/new?title=Realm%20migration%20issue ({t.Exception.Message})&body=Please%20drag%20the%20""attach_me.zip""%20file%20here!&category=q-a", true);
|
game.OpenUrlExternally(
|
||||||
|
$@"https://github.com/ppy/osu/discussions/new?title=Realm%20migration%20issue ({t.Exception.Message})&body=Please%20drag%20the%20""attach_me.zip""%20file%20here!&category=q-a",
|
||||||
|
true);
|
||||||
|
|
||||||
const string attachment_filename = "attach_me.zip";
|
const string attachment_filename = "attach_me.zip";
|
||||||
const string backup_folder = "backups";
|
const string backup_folder = "backups";
|
||||||
|
@ -13,6 +13,7 @@ using System.Linq.Expressions;
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using osu.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Development;
|
using osu.Framework.Development;
|
||||||
using osu.Framework.Input.Bindings;
|
using osu.Framework.Input.Bindings;
|
||||||
@ -293,7 +294,18 @@ namespace osu.Game.Database
|
|||||||
/// Compact this realm.
|
/// Compact this realm.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public bool Compact() => Realm.Compact(getConfiguration());
|
public bool Compact()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return Realm.Compact(getConfiguration());
|
||||||
|
}
|
||||||
|
// Catch can be removed along with entity framework. Is specifically to allow a failure message to arrive to the user (see similar catches in EFToRealmMigrator).
|
||||||
|
catch (AggregateException ae) when (RuntimeInfo.OS == RuntimeInfo.Platform.macOS && ae.Flatten().InnerException is TypeInitializationException)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Run work on realm with a return value.
|
/// Run work on realm with a return value.
|
||||||
@ -542,6 +554,11 @@ namespace osu.Game.Database
|
|||||||
|
|
||||||
return Realm.GetInstance(getConfiguration());
|
return Realm.GetInstance(getConfiguration());
|
||||||
}
|
}
|
||||||
|
// Catch can be removed along with entity framework. Is specifically to allow a failure message to arrive to the user (see similar catches in EFToRealmMigrator).
|
||||||
|
catch (AggregateException ae) when (RuntimeInfo.OS == RuntimeInfo.Platform.macOS && ae.Flatten().InnerException is TypeInitializationException)
|
||||||
|
{
|
||||||
|
return Realm.GetInstance();
|
||||||
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
if (tookSemaphoreLock)
|
if (tookSemaphoreLock)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user