From d7d4b34c8aa560c847c9e4c4a14de65a8826b923 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 19 Sep 2021 12:38:28 -0500 Subject: consolidate some interfaces and classes --- src/slskd/Application/Application.cs | 6 +++ src/slskd/Application/IApplication.cs | 28 ------------- src/slskd/Application/ISharedFileCache.cs | 68 ------------------------------- src/slskd/Application/SharedFileCache.cs | 45 ++++++++++++++++++++ 4 files changed, 51 insertions(+), 96 deletions(-) delete mode 100644 src/slskd/Application/IApplication.cs delete mode 100644 src/slskd/Application/ISharedFileCache.cs (limited to 'src') diff --git a/src/slskd/Application/Application.cs b/src/slskd/Application/Application.cs index f167e673..32c02f64 100644 --- a/src/slskd/Application/Application.cs +++ b/src/slskd/Application/Application.cs @@ -39,6 +39,12 @@ namespace slskd using Soulseek; using Soulseek.Diagnostics; + public interface IApplication : IHostedService + { + public Task CheckVersionAsync(); + public Task RescanSharesAsync(); + } + public sealed class Application : IApplication { private static readonly int ReconnectMaxDelayMilliseconds = 300000; // 5 minutes diff --git a/src/slskd/Application/IApplication.cs b/src/slskd/Application/IApplication.cs deleted file mode 100644 index 18e4ad89..00000000 --- a/src/slskd/Application/IApplication.cs +++ /dev/null @@ -1,28 +0,0 @@ -// -// 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/. -// - -namespace slskd -{ - using System.Threading.Tasks; - using Microsoft.Extensions.Hosting; - - public interface IApplication : IHostedService - { - public Task CheckVersionAsync(); - public Task RescanSharesAsync(); - } -} \ No newline at end of file diff --git a/src/slskd/Application/ISharedFileCache.cs b/src/slskd/Application/ISharedFileCache.cs deleted file mode 100644 index 9d19d72f..00000000 --- a/src/slskd/Application/ISharedFileCache.cs +++ /dev/null @@ -1,68 +0,0 @@ -// -// 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/. -// - -namespace slskd -{ - using System.Collections.Generic; - using System.Threading.Tasks; - using Soulseek; - - /// - /// Shared file cache. - /// - public interface ISharedFileCache - { - /// - /// Gets the cache state monitor. - /// - IStateMonitor StateMonitor { get; } - - /// - /// Returns the contents of the cache. - /// - /// The contents of the cache. - IEnumerable Browse(); - - /// - /// Scans the configured shares and fills the cache. - /// - /// The operation context. - Task FillAsync(); - - /// - /// Returns the contents of the specified . - /// - /// The directory for which the contents are to be listed. - /// The contents of the directory. - Directory List(string directory); - - /// - /// Substitutes the mask in the specified with the original path, if the mask is tracked - /// by the cache. - /// - /// The fully qualified filename to unmask. - /// The unmasked filename. - public string Resolve(string filename); - - /// - /// Searches the cache for the specified and returns the matching files. - /// - /// The query for which to search. - /// The matching files. - Task> SearchAsync(SearchQuery query); - } -} \ No newline at end of file diff --git a/src/slskd/Application/SharedFileCache.cs b/src/slskd/Application/SharedFileCache.cs index e1f3e96d..71d1bae1 100644 --- a/src/slskd/Application/SharedFileCache.cs +++ b/src/slskd/Application/SharedFileCache.cs @@ -32,6 +32,51 @@ namespace slskd using Serilog; using Soulseek; + /// + /// Shared file cache. + /// + public interface ISharedFileCache + { + /// + /// Gets the cache state monitor. + /// + IStateMonitor StateMonitor { get; } + + /// + /// Returns the contents of the cache. + /// + /// The contents of the cache. + IEnumerable Browse(); + + /// + /// Scans the configured shares and fills the cache. + /// + /// The operation context. + Task FillAsync(); + + /// + /// Returns the contents of the specified . + /// + /// The directory for which the contents are to be listed. + /// The contents of the directory. + Directory List(string directory); + + /// + /// Substitutes the mask in the specified with the original path, if the mask is tracked + /// by the cache. + /// + /// The fully qualified filename to unmask. + /// The unmasked filename. + public string Resolve(string filename); + + /// + /// Searches the cache for the specified and returns the matching files. + /// + /// The query for which to search. + /// The matching files. + Task> SearchAsync(SearchQuery query); + } + /// /// Shared file cache. /// -- cgit v1.2.3