Fix lookup cache throwing a null reference if no matches were successful

This commit is contained in:
Dean Herbert 2020-12-28 14:56:29 +09:00
parent 6849eabf2c
commit 4d61c143db

View File

@ -72,6 +72,7 @@ namespace osu.Game.Database
var request = new GetUsersRequest(userTasks.Keys.ToArray()); var request = new GetUsersRequest(userTasks.Keys.ToArray());
// rather than queueing, we maintain our own single-threaded request stream. // rather than queueing, we maintain our own single-threaded request stream.
// todo: we probably want retry logic here.
api.Perform(request); api.Perform(request);
// Create a new request task if there's still more users to query. // Create a new request task if there's still more users to query.
@ -82,14 +83,19 @@ namespace osu.Game.Database
createNewTask(); createNewTask();
} }
foreach (var user in request.Result.Users) List<User> foundUsers = request.Result?.Users;
{
if (userTasks.TryGetValue(user.Id, out var tasks))
{
foreach (var task in tasks)
task.SetResult(user);
userTasks.Remove(user.Id); if (foundUsers != null)
{
foreach (var user in foundUsers)
{
if (userTasks.TryGetValue(user.Id, out var tasks))
{
foreach (var task in tasks)
task.SetResult(user);
userTasks.Remove(user.Id);
}
} }
} }