diff options
| author | JP Dillingham <jpdillingham@gmail.com> | 2021-12-06 19:11:23 -0600 |
|---|---|---|
| committer | JP Dillingham <jpdillingham@gmail.com> | 2021-12-06 19:11:23 -0600 |
| commit | f7f3f51aa9dc33a2ed3642dacb534b58d769cdab (patch) | |
| tree | 58f3d2c1c1c4fb9f9b73e33259caf4b012045016 /src/slskd/Core | |
| parent | 39e26f9a940400102bb0b86e259d836362a95cea (diff) | |
| download | slskd-f7f3f51aa9dc33a2ed3642dacb534b58d769cdab.tar.gz | |
consolidate options controllers
Diffstat (limited to 'src/slskd/Core')
| -rw-r--r-- | src/slskd/Core/API/Controllers/ApplicationController.cs | 22 | ||||
| -rw-r--r-- | src/slskd/Core/API/Controllers/ConfigurationController.cs | 76 |
2 files changed, 22 insertions, 76 deletions
diff --git a/src/slskd/Core/API/Controllers/ApplicationController.cs b/src/slskd/Core/API/Controllers/ApplicationController.cs index 82b1d6c5..d7beed6a 100644 --- a/src/slskd/Core/API/Controllers/ApplicationController.cs +++ b/src/slskd/Core/API/Controllers/ApplicationController.cs @@ -69,6 +69,13 @@ namespace slskd.Core.API public IActionResult Shutdown() { Lifetime.StopApplication(); + + Task.Run(async () => + { + await Task.Delay(500); + Environment.Exit(0); + }); + return NoContent(); } @@ -126,5 +133,20 @@ namespace slskd.Core.API return Ok(); } + + [HttpPut] + [Route("shares")] + [Authorize] + public IActionResult RescanSharesAsync() + { + if (ApplicationStateMonitor.CurrentValue.SharedFileCache.Filling) + { + return Conflict("A share scan is already in progress."); + } + + _ = Application.RescanSharesAsync(); + + return Ok(); + } } } diff --git a/src/slskd/Core/API/Controllers/ConfigurationController.cs b/src/slskd/Core/API/Controllers/ConfigurationController.cs deleted file mode 100644 index a7925174..00000000 --- a/src/slskd/Core/API/Controllers/ConfigurationController.cs +++ /dev/null @@ -1,76 +0,0 @@ -// <copyright file="ConfigurationController.cs" company="slskd Team"> -// Copyright (c) slskd Team. All rights reserved. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published -// by the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see https://www.gnu.org/licenses/. -// </copyright> - -using Microsoft.Extensions.Options; - -namespace slskd.Core.API -{ - using System; - using Microsoft.AspNetCore.Authorization; - using Microsoft.AspNetCore.Mvc; - using Serilog; - using IOFile = System.IO.File; - - /// <summary> - /// Configuration. - /// </summary> - [Route("api/v{version:apiVersion}/[controller]")] - [ApiVersion("0")] - [ApiController] - [Produces("application/json")] - [Consumes("application/json")] - public class ConfigurationController : ControllerBase - { - public ConfigurationController( - IApplication application, - IOptionsSnapshot<Options> optionsShapshot, - IStateMonitor<State> applicationStateMonitor) - { - Application = application; - OptionsSnapshot = optionsShapshot; - ApplicationStateMonitor = applicationStateMonitor; - } - - private IApplication Application { get; } - private IOptionsSnapshot<Options> OptionsSnapshot { get; } - private IStateMonitor<State> ApplicationStateMonitor { get; } - private ILogger Logger { get; set; } = Log.ForContext(typeof(Program)); - - [HttpGet] - [Route("")] - [Authorize] - public IActionResult GetOptions() - { - return Ok(OptionsSnapshot.Value); - } - - [HttpPut] - [Route("shares")] - [Authorize] - public IActionResult RescanSharesAsync() - { - if (ApplicationStateMonitor.CurrentValue.SharedFileCache.Filling) - { - return Conflict("A share scan is already in progress."); - } - - _ = Application.RescanSharesAsync(); - - return Ok(); - } - } -} |
