aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Core/API/Controllers
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2025-07-11 17:52:57 -0500
committerJP Dillingham <jp@dillingham.me>2025-07-11 17:52:57 -0500
commit7d302ce2a65bac34f0795ce5eafb3e06b746872d (patch)
tree4947a95b8a97a531ca1003d4a03017312023ceac /src/slskd/Core/API/Controllers
parent8cbcf622764a627d53505962e34695be2f4dbda0 (diff)
downloadslskd-7d302ce2a65bac34f0795ce5eafb3e06b746872d.tar.gz
return 205/ResetContent if retry loop is restarted by API call
Diffstat (limited to 'src/slskd/Core/API/Controllers')
-rw-r--r--src/slskd/Core/API/Controllers/ServerController.cs17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/slskd/Core/API/Controllers/ServerController.cs b/src/slskd/Core/API/Controllers/ServerController.cs
index aceaeec9..da777b02 100644
--- a/src/slskd/Core/API/Controllers/ServerController.cs
+++ b/src/slskd/Core/API/Controllers/ServerController.cs
@@ -21,6 +21,7 @@ namespace slskd.Core.API
{
using Asp.Versioning;
using Microsoft.AspNetCore.Authorization;
+ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Soulseek;
@@ -36,7 +37,7 @@ namespace slskd.Core.API
{
public ServerController(
ISoulseekClient soulseekClient,
- IConnectionWatchdog connectionWatchdog,
+ ConnectionWatchdog connectionWatchdog,
IOptionsSnapshot<Options> optionsSnapshot,
IStateSnapshot<State> stateSnapshot)
{
@@ -47,7 +48,7 @@ namespace slskd.Core.API
}
private ISoulseekClient Client { get; }
- private IConnectionWatchdog ConnectionWatchdog { get; }
+ private ConnectionWatchdog ConnectionWatchdog { get; }
private IOptionsSnapshot<Options> OptionsSnapshot { get; }
private IStateSnapshot<State> StateSnapshot { get; }
@@ -59,6 +60,7 @@ namespace slskd.Core.API
[Route("")]
[Authorize(Policy = AuthPolicy.Any)]
[ProducesResponseType(200)]
+ [ProducesResponseType(StatusCodes.Status205ResetContent)]
[ProducesResponseType(403)]
public IActionResult Connect()
{
@@ -67,10 +69,19 @@ namespace slskd.Core.API
return Forbid();
}
- // we use the watchdog here so that we get the correct auto-reconnect behavior
+ // if the watchdog is already enabled, we're already attempting to connect. the user might have changed something
+ // or perhaps is just being impatient; either way, restart the retry loop so they can see results faster
+ // remember, we may be in a ~5 minute delay at this moment
+ if (ConnectionWatchdog.IsEnabled)
+ {
+ ConnectionWatchdog.Restart();
+ return StatusCode(StatusCodes.Status205ResetContent);
+ }
+
if (!ConnectionWatchdog.IsEnabled)
{
ConnectionWatchdog.Start();
+ return Ok();
}
return Ok();