diff --git a/osu.Game/Online/API/APIAccess.cs b/osu.Game/Online/API/APIAccess.cs
index 88f9b3f242..479fc99805 100644
--- a/osu.Game/Online/API/APIAccess.cs
+++ b/osu.Game/Online/API/APIAccess.cs
@@ -238,12 +238,13 @@ namespace osu.Game.Online.API
/// Whether the connection attempt was successful.
private void attemptConnect()
{
- Scheduler.Add(setPlaceholderLocalUser, false);
+ if (localUser.IsDefault)
+ Scheduler.Add(setPlaceholderLocalUser, false);
// save the username at this point, if the user requested for it to be.
config.SetValue(OsuSetting.Username, config.Get(OsuSetting.SaveUsername) ? ProvidedUsername : string.Empty);
- if (!authentication.HasValidAccessToken)
+ if (!authentication.HasValidAccessToken && HasLogin)
{
state.Value = APIState.Connecting;
LastLoginError = null;
@@ -252,6 +253,10 @@ namespace osu.Game.Online.API
{
authentication.AuthenticateWithLogin(ProvidedUsername, password);
}
+ catch (WebRequestFlushedException)
+ {
+ return;
+ }
catch (Exception e)
{
//todo: this fails even on network-related issues. we should probably handle those differently.
@@ -312,7 +317,7 @@ namespace osu.Game.Online.API
log.Add(@"Login no longer valid");
Logout();
}
- else
+ else if (ex is not WebRequestFlushedException)
{
state.Value = APIState.Failing;
}
@@ -493,6 +498,11 @@ namespace osu.Game.Online.API
handleWebException(we);
return false;
}
+ catch (WebRequestFlushedException wrf)
+ {
+ log.Add(wrf.Message);
+ return false;
+ }
catch (Exception ex)
{
Logger.Error(ex, "Error occurred while handling an API request.");
@@ -574,7 +584,7 @@ namespace osu.Game.Online.API
if (failOldRequests)
{
foreach (var req in oldQueueRequests)
- req.Fail(new WebException($@"Request failed from flush operation (state {state.Value})"));
+ req.Fail(new WebRequestFlushedException(state.Value));
}
}
}
@@ -605,7 +615,11 @@ namespace osu.Game.Online.API
return;
var friendsReq = new GetFriendsRequest();
- friendsReq.Failure += _ => state.Value = APIState.Failing;
+ friendsReq.Failure += ex =>
+ {
+ if (ex is not WebRequestFlushedException)
+ state.Value = APIState.Failing;
+ };
friendsReq.Success += res =>
{
var existingFriends = friends.Select(f => f.TargetID).ToHashSet();
@@ -630,6 +644,14 @@ namespace osu.Game.Online.API
flushQueue();
cancellationToken.Cancel();
}
+
+ private class WebRequestFlushedException : Exception
+ {
+ public WebRequestFlushedException(APIState state)
+ : base($@"Request failed from flush operation (state {state})")
+ {
+ }
+ }
}
internal class GuestUser : APIUser