rework a lot of stuff: downloads, how to watch a player
This commit is contained in:
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user