Fix StoryboardResourceLookupStore dying on failure to unmap path

Before the introduction of `StoryboardResourceLookupStore`, missing
files would softly fail by use of null fallbacks. After the
aforementioned class was added, however, the fallbacks would not work
anymore if for whatever reason `GetStoragePathFromStoryboardPath()`
failed to unmap the storyboard asset name to a storage path.
This commit is contained in:
Bartłomiej Dach 2023-09-19 20:11:16 +02:00
parent aea7f81f1c
commit ba518e1da8
No known key found for this signature in database

View File

@ -142,14 +142,32 @@ namespace osu.Game.Storyboards.Drawables
public void Dispose() =>
realmFileStore.Dispose();
public byte[] Get(string name) =>
realmFileStore.Get(storyboard.GetStoragePathFromStoryboardPath(name));
public byte[] Get(string name)
{
string? storagePath = storyboard.GetStoragePathFromStoryboardPath(name);
public Task<byte[]> GetAsync(string name, CancellationToken cancellationToken = new CancellationToken()) =>
realmFileStore.GetAsync(storyboard.GetStoragePathFromStoryboardPath(name), cancellationToken);
return string.IsNullOrEmpty(storagePath)
? null!
: realmFileStore.Get(storagePath);
}
public Stream GetStream(string name) =>
realmFileStore.GetStream(storyboard.GetStoragePathFromStoryboardPath(name));
public Task<byte[]> GetAsync(string name, CancellationToken cancellationToken = new CancellationToken())
{
string? storagePath = storyboard.GetStoragePathFromStoryboardPath(name);
return string.IsNullOrEmpty(storagePath)
? Task.FromResult<byte[]>(null!)
: realmFileStore.GetAsync(storagePath, cancellationToken);
}
public Stream? GetStream(string name)
{
string? storagePath = storyboard.GetStoragePathFromStoryboardPath(name);
return string.IsNullOrEmpty(storagePath)
? null
: realmFileStore.GetStream(storagePath);
}
public IEnumerable<string> GetAvailableResources() =>
realmFileStore.GetAvailableResources();