diff options
| author | JP Dillingham <jpdillingham@gmail.com> | 2022-07-16 16:00:39 -0500 |
|---|---|---|
| committer | JP Dillingham <jpdillingham@gmail.com> | 2022-07-16 16:00:39 -0500 |
| commit | a0a38f224acb405b323da8d6336c37fe67aa4ac3 (patch) | |
| tree | f746ff736665d9567e4edfca0c508f2e57a87336 /src | |
| parent | 71739c2daf8ed3b0d878b1df7c432d7ff0dc6789 (diff) | |
| download | slskd-a0a38f224acb405b323da8d6336c37fe67aa4ac3.tar.gz | |
add Transfer
Diffstat (limited to 'src')
| -rw-r--r-- | src/slskd/Transfers/Types/Transfer.cs | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/slskd/Transfers/Types/Transfer.cs b/src/slskd/Transfers/Types/Transfer.cs new file mode 100644 index 00000000..514d2c12 --- /dev/null +++ b/src/slskd/Transfers/Types/Transfer.cs @@ -0,0 +1,54 @@ +// <copyright file="Transfer.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 +{ + using System; + using System.ComponentModel.DataAnnotations; + using System.ComponentModel.DataAnnotations.Schema; + using Soulseek; + + public class Transfer + { + [Key] + public Guid Id { get; init; } + public string Username { get; init; } + public TransferDirection Direction { get; init; } + public string Filename { get; init; } + public long Size { get; set; } + public long StartOffset { get; init; } + + public TransferStates State { get; set; } + public DateTime RequestedAt { get; set; } + public DateTime? EnqueuedAt { get; set; } + public DateTime? StartedAt { get; set; } + public DateTime? EndedAt { get; set; } + public long BytesTransferred { get; set; } + public double AverageSpeed { get; set; } + + public Exception Exception { get; set; } + + [NotMapped] + public long BytesRemaining => Size - BytesTransferred : null; + [NotMapped] + public TimeSpan? ElapsedTime => StartedAt == null ? null : (EndedAt ?? DateTime.UtcNow) - StartedAt.Value; + [NotMapped] + public double PercentComplete => Size == 0 ? 0 : (BytesTransferred / (double)Size) * 100; + [NotMapped] + public TimeSpan? RemainingTime => AverageSpeed == 0 ? null : TimeSpan.FromSeconds(BytesRemaining / AverageSpeed); + } +}
\ No newline at end of file |
