1
0
mirror of https://github.com/chylex/Discord-History-Tracker.git synced 2025-02-22 22:46:01 +01:00
Discord-History-Tracker/app/Server/Download/DownloadItem.cs
2025-02-03 12:28:07 +01:00

22 lines
721 B
C#

using System;
using System.Net;
using DHT.Server.Data;
namespace DHT.Server.Download;
public readonly struct DownloadItem {
public string NormalizedUrl { get; init; }
public string DownloadUrl { get; init; }
public string? Type { get; init; }
public ulong? Size { get; init; }
internal Data.Download ToSuccess(long size) {
return new Data.Download(NormalizedUrl, DownloadUrl, DownloadStatus.Success, Type, (ulong) Math.Max(size, val2: 0));
}
internal Data.Download ToFailure(HttpStatusCode? statusCode = null) {
DownloadStatus status = statusCode.HasValue ? (DownloadStatus) (int) statusCode : DownloadStatus.GenericError;
return new Data.Download(NormalizedUrl, DownloadUrl, status, Type, Size);
}
}