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,7 +83,11 @@ namespace osu.Game.Database
createNewTask(); createNewTask();
} }
foreach (var user in request.Result.Users) List<User> foundUsers = request.Result?.Users;
if (foundUsers != null)
{
foreach (var user in foundUsers)
{ {
if (userTasks.TryGetValue(user.Id, out var tasks)) if (userTasks.TryGetValue(user.Id, out var tasks))
{ {
@ -92,6 +97,7 @@ namespace osu.Game.Database
userTasks.Remove(user.Id); userTasks.Remove(user.Id);
} }
} }
}
// if any tasks remain which were not satisfied, return null. // if any tasks remain which were not satisfied, return null.
foreach (var tasks in userTasks.Values) foreach (var tasks in userTasks.Values)