From 43f3bf2d128dc7e44043a8ef2199d75cdb0d3d4b Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Tue, 3 Aug 2021 09:25:10 -0500 Subject: add plumbing to rescan shares via API --- .../Application/Management/ManagementService.cs | 38 +++++++++++++++------- 1 file changed, 27 insertions(+), 11 deletions(-) (limited to 'src/slskd/Application/Management/ManagementService.cs') diff --git a/src/slskd/Application/Management/ManagementService.cs b/src/slskd/Application/Management/ManagementService.cs index 66ed2b97..2f79f496 100644 --- a/src/slskd/Application/Management/ManagementService.cs +++ b/src/slskd/Application/Management/ManagementService.cs @@ -1,18 +1,13 @@ // // 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 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. +// 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/. +// 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/. // using Microsoft.Extensions.Options; @@ -21,6 +16,7 @@ namespace slskd.Management { using System; using System.Threading.Tasks; + using slskd.Shares; using Soulseek; /// @@ -32,18 +28,26 @@ namespace slskd.Management /// Initializes a new instance of the class. /// /// The options monitor used to derive application options. + /// The state monitor for application service state. /// The Soulseek client. + /// The shared file cache. public ManagementService( IOptionsMonitor optionsMonitor, - ISoulseekClient soulseekClient) + IStateMonitor serviceStateMonitor, + ISoulseekClient soulseekClient, + ISharedFileCache sharedFileCache) { OptionsMonitor = optionsMonitor; + ServiceStateMonitor = serviceStateMonitor; Client = soulseekClient; + SharedFileCache = sharedFileCache; } private ISoulseekClient Client { get; } private Options Options => OptionsMonitor.CurrentValue; private IOptionsMonitor OptionsMonitor { get; } + private IStateMonitor ServiceStateMonitor { get; } + private ISharedFileCache SharedFileCache { get; } /// /// Connects the Soulseek client to the server using the configured username and password. @@ -72,5 +76,17 @@ namespace slskd.Management State = Client.State, Username = Client.Username, }; + + /// + /// Gets the current state of the slskd service. + /// + /// + public ServiceState GetServiceState() => ServiceStateMonitor.CurrentValue; + + /// + /// Re-scans shared directories. + /// + /// The operation context. + public Task RescanSharesAsync() => SharedFileCache.FillAsync(); } } \ No newline at end of file -- cgit v1.2.3