Skip to content

Commit

Permalink
Merge pull request #29562 from peppy/remove-migration-leftover-message
Browse files Browse the repository at this point in the history
Remove "leftover files" notification when migration partly fails
  • Loading branch information
bdach authored Aug 22, 2024
2 parents a32a817 + 1859e17 commit b3e961f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 33 deletions.
5 changes: 0 additions & 5 deletions osu.Game/Localisation/MaintenanceSettingsStrings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ public static class MaintenanceSettingsStrings
/// </summary>
public static LocalisableString ProhibitedInteractDuringMigration => new TranslatableString(getKey(@"prohibited_interact_during_migration"), @"Please avoid interacting with the game!");

/// <summary>
/// "Some files couldn't be cleaned up during migration. Clicking this notification will open the folder so you can manually clean things up."
/// </summary>
public static LocalisableString FailedCleanupNotification => new TranslatableString(getKey(@"failed_cleanup_notification"), @"Some files couldn't be cleaned up during migration. Clicking this notification will open the folder so you can manually clean things up.");

/// <summary>
/// "Please select a new location"
/// </summary>
Expand Down
10 changes: 8 additions & 2 deletions osu.Game/OsuGameBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,12 @@ public virtual void AttemptExit()
/// <returns>Whether a restart operation was queued.</returns>
public virtual bool RestartAppWhenExited() => false;

/// <summary>
/// Perform migration of user data to a specified path.
/// </summary>
/// <param name="path">The path to migrate to.</param>
/// <returns>Whether migration succeeded to completion. If <c>false</c>, some files were left behind.</returns>
/// <exception cref="TimeoutException"></exception>
public bool Migrate(string path)
{
Logger.Log($@"Migrating osu! data from ""{Storage.GetFullPath(string.Empty)}"" to ""{path}""...");
Expand Down Expand Up @@ -542,10 +548,10 @@ public bool Migrate(string path)
if (!readyToRun.Wait(30000) || !success)
throw new TimeoutException("Attempting to block for migration took too long.");

bool? cleanupSucceded = (Storage as OsuStorage)?.Migrate(Host.GetStorage(path));
bool? cleanupSucceeded = (Storage as OsuStorage)?.Migrate(Host.GetStorage(path));

Logger.Log(@"Migration complete!");
return cleanupSucceded != false;
return cleanupSucceeded != false;
}
finally
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,14 @@
using System.IO;
using System.Threading.Tasks;
using osu.Framework.Allocation;
using osu.Framework.Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Logging;
using osu.Framework.Platform;
using osu.Framework.Screens;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Localisation;
using osu.Game.Overlays.Notifications;
using osu.Game.Screens;
using osuTK;

Expand All @@ -29,15 +26,6 @@ public partial class MigrationRunScreen : OsuScreen
[Resolved(canBeNull: true)]
private OsuGame game { get; set; }

[Resolved]
private INotificationOverlay notifications { get; set; }

[Resolved]
private Storage storage { get; set; }

[Resolved]
private GameHost host { get; set; }

public override bool AllowBackButton => false;

public override bool AllowExternalScreenChange => false;
Expand Down Expand Up @@ -99,27 +87,13 @@ protected override void LoadComplete()

Beatmap.Value = Beatmap.Default;

var originalStorage = new NativeStorage(storage.GetFullPath(string.Empty), host);

migrationTask = Task.Run(PerformMigration)
.ContinueWith(task =>
{
if (task.IsFaulted)
{
Logger.Error(task.Exception, $"Error during migration: {task.Exception?.Message}");
}
else if (!task.GetResultSafely())
{
notifications.Post(new SimpleNotification
{
Text = MaintenanceSettingsStrings.FailedCleanupNotification,
Activated = () =>
{
originalStorage.PresentExternally();
return true;
}
});
}

Schedule(this.Exit);
});
Expand Down

0 comments on commit b3e961f

Please sign in to comment.