diff options
| author | JP Dillingham <jpdillingham@gmail.com> | 2022-07-25 21:11:50 -0500 |
|---|---|---|
| committer | JP Dillingham <jpdillingham@gmail.com> | 2022-07-25 21:11:50 -0500 |
| commit | a85d1a5ba9b9aa02fc53db008426712394aa9f48 (patch) | |
| tree | eb35ef7de9ed7e008e67bcce7f3e386a1f1d0f3d /src | |
| parent | 14473b6f37af70190c854f8e45fbf568b1677ab8 (diff) | |
| download | slskd-a85d1a5ba9b9aa02fc53db008426712394aa9f48.tar.gz | |
extract IUploadService, prep for DbContext
Diffstat (limited to 'src')
| -rw-r--r-- | src/slskd/Program.cs | 2 | ||||
| -rw-r--r-- | src/slskd/Transfers/TransferService.cs | 21 | ||||
| -rw-r--r-- | src/slskd/Transfers/Uploads/IUploadService.cs | 35 | ||||
| -rw-r--r-- | src/slskd/Transfers/Uploads/UploadService.cs | 33 |
4 files changed, 56 insertions, 35 deletions
diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs index 1d845ab1..ac5bf99b 100644 --- a/src/slskd/Program.cs +++ b/src/slskd/Program.cs @@ -61,6 +61,7 @@ namespace slskd using slskd.Shares; using slskd.Transfers; using slskd.Transfers.Downloads; + using slskd.Transfers.Uploads; using slskd.Users; using slskd.Validation; using Soulseek; @@ -465,6 +466,7 @@ namespace slskd services.AddSingleton<ITransferService, TransferService>(); services.AddSingleton<IDownloadService, DownloadService>(); + services.AddSingleton<IUploadService, UploadService>(); services.AddSingleton<IFTPClientFactory, FTPClientFactory>(); services.AddSingleton<IFTPService, FTPService>(); diff --git a/src/slskd/Transfers/TransferService.cs b/src/slskd/Transfers/TransferService.cs index 253dc318..20b9b8e3 100644 --- a/src/slskd/Transfers/TransferService.cs +++ b/src/slskd/Transfers/TransferService.cs @@ -15,13 +15,10 @@ // along with this program. If not, see https://www.gnu.org/licenses/. // </copyright> -using Microsoft.Extensions.Options; - namespace slskd.Transfers { using slskd.Transfers.Downloads; using slskd.Transfers.Uploads; - using slskd.Users; /// <summary> /// Manages transfers. @@ -47,24 +44,11 @@ namespace slskd.Transfers /// <summary> /// Initializes a new instance of the <see cref="TransferService"/> class. /// </summary> - /// <param name="userService">The UserService instance to use.</param> - /// <param name="optionsMonitor">The OptionsMonitor instance to use.</param> - /// <param name="uploadService">The optional UploadService instance to use.</param> public TransferService( - IUserService userService, - IOptionsMonitor<Options> optionsMonitor, IUploadService uploadService = null, IDownloadService downloadService = null) { - Users = userService; - OptionsMonitor = optionsMonitor; - - Uploads = uploadService ?? new UploadService() - { - Governor = new UploadGovernor(userService: Users, optionsMonitor: OptionsMonitor), - Queue = new UploadQueue(userService: Users, optionsMonitor: OptionsMonitor), - }; - + Uploads = uploadService; Downloads = downloadService; } @@ -77,8 +61,5 @@ namespace slskd.Transfers /// Gets the download service. /// </summary> public IDownloadService Downloads { get; init; } - - private IOptionsMonitor<Options> OptionsMonitor { get; init; } - private IUserService Users { get; init; } } }
\ No newline at end of file diff --git a/src/slskd/Transfers/Uploads/IUploadService.cs b/src/slskd/Transfers/Uploads/IUploadService.cs new file mode 100644 index 00000000..71fc6067 --- /dev/null +++ b/src/slskd/Transfers/Uploads/IUploadService.cs @@ -0,0 +1,35 @@ +// <copyright file="IUploadService.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> + +namespace slskd.Transfers.Uploads +{ + /// <summary> + /// Manages uploads. + /// </summary> + public interface IUploadService + { + /// <summary> + /// Gets the upload governor. + /// </summary> + IUploadGovernor Governor { get; } + + /// <summary> + /// Gets the upload queue. + /// </summary> + IUploadQueue Queue { get; } + } +}
\ No newline at end of file diff --git a/src/slskd/Transfers/Uploads/UploadService.cs b/src/slskd/Transfers/Uploads/UploadService.cs index f88e80a8..10e82d7f 100644 --- a/src/slskd/Transfers/Uploads/UploadService.cs +++ b/src/slskd/Transfers/Uploads/UploadService.cs @@ -15,29 +15,32 @@ // along with this program. If not, see https://www.gnu.org/licenses/. // </copyright> + +using Microsoft.Extensions.Options; + namespace slskd.Transfers.Uploads { - /// <summary> - /// Manages uploads. - /// </summary> - public interface IUploadService - { - /// <summary> - /// Gets the upload governor. - /// </summary> - IUploadGovernor Governor { get; } - - /// <summary> - /// Gets the upload queue. - /// </summary> - IUploadQueue Queue { get; } - } + using Microsoft.EntityFrameworkCore; + using slskd.Users; /// <summary> /// Manages uploads. /// </summary> public class UploadService : IUploadService { + public UploadService( + IUserService userService, + IOptionsMonitor<Options> optionsMonitor, + IDbContextFactory<TransfersDbContext> contextFactory) + { + ContextFactory = contextFactory; + + Governor = new UploadGovernor(userService, optionsMonitor); + Queue = new UploadQueue(userService, optionsMonitor); + } + + private IDbContextFactory<TransfersDbContext> ContextFactory { get; } + /// <summary> /// Gets the upload governor. /// </summary> |
