From 0c13b7b56876d799a1189a406ca23640bbc8cf76 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 13 Feb 2021 17:01:46 -0600 Subject: fix dto refs --- src/slskd/Trackers/ITransferTracker.cs | 25 +++++++++++--- src/slskd/Trackers/TransferTracker.cs | 59 ++++++++++++++++++++++------------ 2 files changed, 59 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/slskd/Trackers/ITransferTracker.cs b/src/slskd/Trackers/ITransferTracker.cs index f55a23ac..b16311f8 100644 --- a/src/slskd/Trackers/ITransferTracker.cs +++ b/src/slskd/Trackers/ITransferTracker.cs @@ -1,8 +1,25 @@ -namespace slskd.Trackers +// +// 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.Trackers { - using Soulseek; using System.Collections.Concurrent; using System.Threading; + using Soulseek; /// /// Tracks transfers. @@ -12,7 +29,7 @@ /// /// Tracked transfers. /// - ConcurrentDictionary>> Transfers { get; } + ConcurrentDictionary>> Transfers { get; } /// /// Adds or updates a tracked transfer. @@ -35,6 +52,6 @@ /// /// /// - bool TryGet(TransferDirection direction, string username, string id, out (DTO.Transfer Transfer, CancellationTokenSource CancellationTokenSource) transfer); + bool TryGet(TransferDirection direction, string username, string id, out (API.DTO.Transfer Transfer, CancellationTokenSource CancellationTokenSource) transfer); } } \ No newline at end of file diff --git a/src/slskd/Trackers/TransferTracker.cs b/src/slskd/Trackers/TransferTracker.cs index 8739b7ca..6efa7345 100644 --- a/src/slskd/Trackers/TransferTracker.cs +++ b/src/slskd/Trackers/TransferTracker.cs @@ -1,8 +1,25 @@ -namespace slskd.Trackers +// +// 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.Trackers { using System.Collections.Concurrent; - using System.Threading; using System.Linq; + using System.Threading; using Soulseek; /// @@ -16,12 +33,12 @@ /// /// /// - public static ConcurrentDictionary> WithDirection( - this ConcurrentDictionary>> allTransfers, + public static ConcurrentDictionary> WithDirection( + this ConcurrentDictionary>> allTransfers, TransferDirection direction) { allTransfers.TryGetValue(direction, out var transfers); - return transfers ?? new ConcurrentDictionary>(); + return transfers ?? new ConcurrentDictionary>(); } /// @@ -30,7 +47,7 @@ /// /// public static object ToMap( - this ConcurrentDictionary> directedTransfers) + this ConcurrentDictionary> directedTransfers) { return directedTransfers.Select(u => new { @@ -47,12 +64,12 @@ /// /// /// - public static ConcurrentDictionary FromUser( - this ConcurrentDictionary> directedTransfers, + public static ConcurrentDictionary FromUser( + this ConcurrentDictionary> directedTransfers, string username) { directedTransfers.TryGetValue(username, out var transfers); - return transfers ?? new ConcurrentDictionary(); + return transfers ?? new ConcurrentDictionary(); } /// @@ -60,7 +77,7 @@ /// /// public static object ToMap( - this ConcurrentDictionary userTransfers) + this ConcurrentDictionary userTransfers) { return userTransfers.Values .GroupBy(f => f.Transfer.Filename.DirectoryName()) @@ -73,8 +90,8 @@ /// /// /// - public static (DTO.Transfer Transfer, CancellationTokenSource CancellationTokenSource) WithId( - this ConcurrentDictionary userTransfers, + public static (API.DTO.Transfer Transfer, CancellationTokenSource CancellationTokenSource) WithId( + this ConcurrentDictionary userTransfers, string id) { userTransfers.TryGetValue(id, out var transfer); @@ -90,16 +107,16 @@ /// /// Tracked transfers. /// - public ConcurrentDictionary>> Transfers { get; private set; } = - new ConcurrentDictionary>>(); + public ConcurrentDictionary>> Transfers { get; private set; } = + new ConcurrentDictionary>>(); /// /// Initializes a new instance of the class. /// public TransferTracker() { - Transfers.TryAdd(TransferDirection.Download, new ConcurrentDictionary>()); - Transfers.TryAdd(TransferDirection.Upload, new ConcurrentDictionary>()); + Transfers.TryAdd(TransferDirection.Download, new ConcurrentDictionary>()); + Transfers.TryAdd(TransferDirection.Upload, new ConcurrentDictionary>()); } /// @@ -113,7 +130,7 @@ direction.AddOrUpdate(args.Transfer.Username, GetNewDictionaryForUser(args, cancellationTokenSource), (user, dict) => { - var transfer = DTO.Transfer.FromSoulseekTransfer(args.Transfer); + var transfer = API.DTO.Transfer.FromSoulseekTransfer(args.Transfer); dict.AddOrUpdate(transfer.Id, (transfer, cancellationTokenSource), (id, record) => (transfer, cancellationTokenSource)); return dict; }); @@ -151,7 +168,7 @@ /// /// /// - public bool TryGet(TransferDirection direction, string username, string id, out (DTO.Transfer Transfer, CancellationTokenSource CancellationTokenSource) transfer) + public bool TryGet(TransferDirection direction, string username, string id, out (API.DTO.Transfer Transfer, CancellationTokenSource CancellationTokenSource) transfer) { transfer = default; @@ -169,10 +186,10 @@ return false; } - private ConcurrentDictionary GetNewDictionaryForUser(TransferEventArgs args, CancellationTokenSource cancellationTokenSource) + private ConcurrentDictionary GetNewDictionaryForUser(TransferEventArgs args, CancellationTokenSource cancellationTokenSource) { - var r = new ConcurrentDictionary(); - var transfer = DTO.Transfer.FromSoulseekTransfer(args.Transfer); + var r = new ConcurrentDictionary(); + var transfer = API.DTO.Transfer.FromSoulseekTransfer(args.Transfer); r.AddOrUpdate(transfer.Id, (transfer, cancellationTokenSource), (id, record) => (transfer, record.CancellationTokenSource)); return r; } -- cgit v1.2.3