From 77201c8144bd88cb5a1f9cc4f5a0a939dd0c46e9 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 17 Sep 2023 16:18:10 -0500 Subject: consolidate I/DownloadService --- src/slskd/Transfers/Downloads/DownloadService.cs | 78 +++++++++++++++++++ src/slskd/Transfers/Downloads/IDownloadService.cs | 94 ----------------------- 2 files changed, 78 insertions(+), 94 deletions(-) delete mode 100644 src/slskd/Transfers/Downloads/IDownloadService.cs (limited to 'src') diff --git a/src/slskd/Transfers/Downloads/DownloadService.cs b/src/slskd/Transfers/Downloads/DownloadService.cs index 827a0528..685bcb43 100644 --- a/src/slskd/Transfers/Downloads/DownloadService.cs +++ b/src/slskd/Transfers/Downloads/DownloadService.cs @@ -33,6 +33,84 @@ namespace slskd.Transfers.Downloads using slskd.Integrations.FTP; using slskd.Relay; + /// + /// Manages downloads. + /// + public interface IDownloadService + { + /// + /// Adds the specified . Supersedes any existing record for the same file and username. + /// + /// This should generally not be called; use EnqueueAsync() instead. + /// + void AddOrSupersede(Transfer transfer); + + /// + /// Enqueues the requested list of . + /// + /// + /// If one file in the specified collection fails, the rest will continue. An will be + /// thrown after all files are dispositioned if any throws. + /// + /// The username of remote user. + /// The list of files to enqueue. + /// The operation context. + /// Thrown when the username is null or an empty string. + /// Thrown when no files are requested. + /// Thrown when at least one of the requested files throws. + Task EnqueueAsync(string username, IEnumerable<(string Filename, long Size)> files); + + /// + /// Finds a single download matching the specified . + /// + /// The expression to use to match downloads. + /// The found transfer, or default if not found. + Transfer Find(Expression> expression); + + /// + /// Retrieves the place in the remote queue for the download matching the specified . + /// + /// The unique identifier for the download. + /// The retrieved place in queue. + Task GetPlaceInQueueAsync(Guid id); + + /// + /// Returns a list of all downloads matching the optional . + /// + /// An optional expression used to match downloads. + /// Optionally include downloads that have been removed previously. + /// The list of downloads matching the specified expression, or all downloads if no expression is specified. + List List(Expression> expression = null, bool includeRemoved = false); + + /// + /// Removes downloads older than the specified . + /// + /// The age after which downloads are eligible for pruning, in hours. + /// An optional, additional state by which downloads are filtered for pruning. + /// The number of pruned downloads. + int Prune(int age, TransferStates state = TransferStates.Completed); + + /// + /// Removes the download matching the specified . + /// + /// This is a soft delete; the record is retained for historical retrieval. + /// The unique identifier of the download. + void Remove(Guid id); + + /// + /// Cancels the download matching the specified , if it is in progress. + /// + /// The unique identifier for the download. + /// A value indicating whether the download was successfully cancelled. + bool TryCancel(Guid id); + + /// + /// Updates the specified . + /// + /// The transfer to update. + void Update(Transfer transfer); + } + /// /// Manages downloads. /// diff --git a/src/slskd/Transfers/Downloads/IDownloadService.cs b/src/slskd/Transfers/Downloads/IDownloadService.cs deleted file mode 100644 index b49d575c..00000000 --- a/src/slskd/Transfers/Downloads/IDownloadService.cs +++ /dev/null @@ -1,94 +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.Transfers.Downloads -{ - using System; - using System.Collections.Generic; - using System.Linq.Expressions; - using System.Threading.Tasks; - - /// - /// Manages downloads. - /// - public interface IDownloadService - { - /// - /// Adds the specified . Supersedes any existing record for the same file and username. - /// - /// This should generally not be called; use EnqueueAsync() instead. - /// - void AddOrSupersede(Transfer transfer); - - /// - /// Enqueues the requested list of . - /// - /// - /// If one file in the specified collection fails, the rest will continue. An will be - /// thrown after all files are dispositioned if any throws. - /// - /// The username of remote user. - /// The list of files to enqueue. - /// The operation context. - /// Thrown when the username is null or an empty string. - /// Thrown when no files are requested. - /// Thrown when at least one of the requested files throws. - Task EnqueueAsync(string username, IEnumerable<(string Filename, long Size)> files); - - /// - /// Finds a single download matching the specified . - /// - /// The expression to use to match downloads. - /// The found transfer, or default if not found. - Transfer Find(Expression> expression); - - /// - /// Retrieves the place in the remote queue for the download matching the specified . - /// - /// The unique identifier for the download. - /// The retrieved place in queue. - Task GetPlaceInQueueAsync(Guid id); - - /// - /// Returns a list of all downloads matching the optional . - /// - /// An optional expression used to match downloads. - /// Optionally include downloads that have been removed previously. - /// The list of downloads matching the specified expression, or all downloads if no expression is specified. - List List(Expression> expression = null, bool includeRemoved = false); - - /// - /// Removes the download matching the specified . - /// - /// This is a soft delete; the record is retained for historical retrieval. - /// The unique identifier of the download. - void Remove(Guid id); - - /// - /// Cancels the download matching the specified , if it is in progress. - /// - /// The unique identifier for the download. - /// A value indicating whether the download was successfully cancelled. - bool TryCancel(Guid id); - - /// - /// Updates the specified . - /// - /// The transfer to update. - void Update(Transfer transfer); - } -} \ No newline at end of file -- cgit v1.2.3