mirror of
https://github.com/ppy/osu.git
synced 2025-02-15 19:33:20 +08:00
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:
parent
aea7f81f1c
commit
ba518e1da8
@ -142,14 +142,32 @@ namespace osu.Game.Storyboards.Drawables
|
|||||||
public void Dispose() =>
|
public void Dispose() =>
|
||||||
realmFileStore.Dispose();
|
realmFileStore.Dispose();
|
||||||
|
|
||||||
public byte[] Get(string name) =>
|
public byte[] Get(string name)
|
||||||
realmFileStore.Get(storyboard.GetStoragePathFromStoryboardPath(name));
|
{
|
||||||
|
string? storagePath = storyboard.GetStoragePathFromStoryboardPath(name);
|
||||||
|
|
||||||
public Task<byte[]> GetAsync(string name, CancellationToken cancellationToken = new CancellationToken()) =>
|
return string.IsNullOrEmpty(storagePath)
|
||||||
realmFileStore.GetAsync(storyboard.GetStoragePathFromStoryboardPath(name), cancellationToken);
|
? null!
|
||||||
|
: realmFileStore.Get(storagePath);
|
||||||
|
}
|
||||||
|
|
||||||
public Stream GetStream(string name) =>
|
public Task<byte[]> GetAsync(string name, CancellationToken cancellationToken = new CancellationToken())
|
||||||
realmFileStore.GetStream(storyboard.GetStoragePathFromStoryboardPath(name));
|
{
|
||||||
|
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() =>
|
public IEnumerable<string> GetAvailableResources() =>
|
||||||
realmFileStore.GetAvailableResources();
|
realmFileStore.GetAvailableResources();
|
||||||
|
Loading…
Reference in New Issue
Block a user