using VoidCat.Model; namespace VoidCat.Services { public interface IFileStore { Task Get(Guid id); Task Ingress(Stream inStream, VoidFileMeta meta, CancellationToken cts); Task Egress(EgressRequest request, Stream outStream, CancellationToken cts); Task UpdateInfo(VoidFile patch, Guid editSecret); IAsyncEnumerable ListFiles(); } public record EgressRequest(Guid Id, IEnumerable Ranges) { } public record RangeRequest(long? TotalSize, long? Start, long? End) { private const long DefaultBufferSize = 1024L * 512L; public long? Size => Start.HasValue ? (End ?? Math.Min(TotalSize!.Value, Start.Value + DefaultBufferSize)) - Start.Value : End; public bool IsForFullFile => Start is 0 && !End.HasValue; /// /// Return Content-Range header content for this range /// /// public string ToContentRange() => $"bytes {Start}-{End ?? (Start + Size - 1L)}/{TotalSize?.ToString() ?? "*"}"; } }