mirror of
https://github.com/Caraxi/mare.client.git
synced 2025-12-12 16:57:22 +01:00
rework a lot of stuff: downloads, how to watch a player
This commit is contained in:
parent
eb39429777
commit
3618540402
18 changed files with 319 additions and 233 deletions
|
|
@ -1,8 +1,42 @@
|
|||
namespace MareSynchronos.WebAPI.Utils;
|
||||
using MareSynchronos.API;
|
||||
|
||||
public class FileTransfer
|
||||
namespace MareSynchronos.WebAPI.Utils;
|
||||
|
||||
public abstract class FileTransfer
|
||||
{
|
||||
protected readonly ITransferFileDto TransferDto;
|
||||
|
||||
protected FileTransfer(ITransferFileDto transferDto)
|
||||
{
|
||||
TransferDto = transferDto;
|
||||
}
|
||||
|
||||
public string ForbiddenBy => TransferDto.ForbiddenBy;
|
||||
public long Transferred { get; set; } = 0;
|
||||
public long Total { get; set; } = 0;
|
||||
public string Hash { get; set; } = string.Empty;
|
||||
public abstract long Total { get; set; }
|
||||
public string Hash => TransferDto.Hash;
|
||||
public bool IsInTransfer => Transferred != Total && Transferred > 0;
|
||||
public bool IsTransferred => Transferred == Total;
|
||||
public virtual bool CanBeTransferred => !TransferDto.IsForbidden;
|
||||
public bool IsForbidden => TransferDto.IsForbidden;
|
||||
}
|
||||
|
||||
public class UploadFileTransfer : FileTransfer
|
||||
{
|
||||
public UploadFileTransfer(UploadFileDto dto) : base(dto) { }
|
||||
public override long Total { get; set; }
|
||||
}
|
||||
|
||||
public class DownloadFileTransfer : FileTransfer
|
||||
{
|
||||
private DownloadFileDto Dto => (DownloadFileDto)TransferDto;
|
||||
public DownloadFileTransfer(DownloadFileDto dto) : base(dto) { }
|
||||
|
||||
public override long Total
|
||||
{
|
||||
set { }
|
||||
get => Dto.Size;
|
||||
}
|
||||
|
||||
public override bool CanBeTransferred => Dto.FileExists && !Dto.IsForbidden && Dto.Size > 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue