mirror of
https://github.com/ppy/osu.git
synced 2024-12-13 08:32:57 +08:00
Add synchronous fetch flow to BeatmapOnlineLookupQueue
The async flow doesn't work great with the realm import process. We might be able to improve on this going forward, but for the time being adding a synchronous path seems safest. After all, we are already an an asynchronous (dedicated) thread pool at this point.
This commit is contained in:
parent
bdb2979b2e
commit
93c78253d6
@ -54,6 +54,12 @@ namespace osu.Game.Beatmaps
|
||||
prepareLocalCache();
|
||||
}
|
||||
|
||||
public void Update(BeatmapSetInfo beatmapSet, CancellationToken cancellationToken)
|
||||
{
|
||||
foreach (var b in beatmapSet.Beatmaps)
|
||||
lookup(beatmapSet, b);
|
||||
}
|
||||
|
||||
public Task UpdateAsync(BeatmapSetInfo beatmapSet, CancellationToken cancellationToken)
|
||||
{
|
||||
return Task.WhenAll(beatmapSet.Beatmaps.Select(b => UpdateAsync(beatmapSet, b, cancellationToken)).ToArray());
|
||||
@ -73,13 +79,17 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
var req = new GetBeatmapRequest(beatmapInfo);
|
||||
|
||||
req.Failure += fail;
|
||||
|
||||
try
|
||||
{
|
||||
// intentionally blocking to limit web request concurrency
|
||||
api.Perform(req);
|
||||
|
||||
if (req.CompletionState == APIRequestCompletionState.Failed)
|
||||
{
|
||||
logForModel(set, $"Online retrieval failed for {beatmapInfo}");
|
||||
beatmapInfo.OnlineID = -1;
|
||||
}
|
||||
|
||||
var res = req.Response;
|
||||
|
||||
if (res != null)
|
||||
@ -99,13 +109,8 @@ namespace osu.Game.Beatmaps
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
fail(e);
|
||||
}
|
||||
|
||||
void fail(Exception e)
|
||||
{
|
||||
beatmapInfo.OnlineID = -1;
|
||||
logForModel(set, $"Online retrieval failed for {beatmapInfo} ({e.Message})");
|
||||
beatmapInfo.OnlineID = -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -71,11 +71,7 @@ namespace osu.Game.Stores
|
||||
|
||||
bool hadOnlineIDs = beatmapSet.Beatmaps.Any(b => b.OnlineID > 0);
|
||||
|
||||
if (onlineLookupQueue != null)
|
||||
{
|
||||
// TODO: this required `BeatmapOnlineLookupQueue` to somehow support new types.
|
||||
// await onlineLookupQueue.UpdateAsync(beatmapSet, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
onlineLookupQueue?.Update(beatmapSet, cancellationToken);
|
||||
|
||||
// ensure at least one beatmap was able to retrieve or keep an online ID, else drop the set ID.
|
||||
if (hadOnlineIDs && !beatmapSet.Beatmaps.Any(b => b.OnlineID > 0))
|
||||
|
Loading…
Reference in New Issue
Block a user