1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-22 17:52:57 +08:00

Merge pull request #30545 from bdach/fix-restore-storage-not-restoring-storage

Fix retry button on storage unavailable dialog not reopening realm if retry succeeds
This commit is contained in:
Dean Herbert 2024-11-11 14:30:50 +09:00 committed by GitHub
commit caedbdeccf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -4,6 +4,7 @@
using System.Collections.Generic;
using osu.Framework.Allocation;
using osu.Framework.Graphics.Sprites;
using osu.Game.Database;
using osu.Game.IO;
using osu.Game.Localisation;
using osu.Game.Overlays;
@ -16,6 +17,9 @@ namespace osu.Game.Screens.Menu
[Resolved]
private IDialogOverlay dialogOverlay { get; set; } = null!;
[Resolved]
private RealmAccess realmAccess { get; set; } = null!;
public StorageErrorDialog(OsuStorage storage, OsuStorageError error)
{
HeaderText = StorageErrorDialogStrings.StorageError;
@ -35,7 +39,15 @@ namespace osu.Game.Screens.Menu
Text = StorageErrorDialogStrings.TryAgain,
Action = () =>
{
if (!storage.TryChangeToCustomStorage(out var nextError))
bool success;
OsuStorageError nextError;
// blocking all operations has a side effect of closing & reopening the realm db,
// which is desirable here since the restoration of the old storage - if it succeeds - means the realm db has moved.
using (realmAccess.BlockAllOperations(@"restoration of previously unavailable storage"))
success = storage.TryChangeToCustomStorage(out nextError);
if (!success)
dialogOverlay.Push(new StorageErrorDialog(storage, nextError));
}
},