mirror of
https://github.com/ppy/osu.git
synced 2025-02-20 08:53:20 +08:00
Ensure intro files exist in storage
Guards against user interdiction. See [https://discord.com/channels/188630481301012481/1097318920991559880/1324765503012601927](recent) but not only case of this occurring.
This commit is contained in:
parent
e15978cc65
commit
72dfdac2e2
@ -20,6 +20,7 @@ using osu.Game.Audio;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Extensions;
|
||||
using osu.Game.Localisation;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Overlays;
|
||||
@ -170,7 +171,14 @@ namespace osu.Game.Screens.Menu
|
||||
if (s.Beatmaps.Count == 0)
|
||||
return;
|
||||
|
||||
initialBeatmap = beatmaps.GetWorkingBeatmap(s.Beatmaps.First());
|
||||
var working = beatmaps.GetWorkingBeatmap(s.Beatmaps.First());
|
||||
|
||||
// Ensure files area actually present on disk.
|
||||
// This is to handle edge cases like users deleting files outside the game and breaking the world.
|
||||
if (!hasAllFiles(working))
|
||||
return;
|
||||
|
||||
initialBeatmap = working;
|
||||
});
|
||||
|
||||
return UsingThemedIntro = initialBeatmap != null;
|
||||
@ -188,6 +196,20 @@ namespace osu.Game.Screens.Menu
|
||||
[Resolved]
|
||||
private INotificationOverlay notifications { get; set; }
|
||||
|
||||
private bool hasAllFiles(WorkingBeatmap working)
|
||||
{
|
||||
foreach (var f in working.BeatmapSetInfo.Files)
|
||||
{
|
||||
using (var str = working.GetStream(f.File.GetStoragePath()))
|
||||
{
|
||||
if (str == null)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void ensureEventuallyArrivingAtMenu()
|
||||
{
|
||||
// This intends to handle the case where an intro may get stuck.
|
||||
|
Loading…
Reference in New Issue
Block a user