Luski.Net/Luski.net/Structures/Public/SocketFile.cs
2024-08-27 10:57:22 -04:00

28 lines
1.0 KiB
C#

using System.IO;
using System.Threading;
using System.Threading.Tasks;
using JacobTechEncryption.Enums;
using Luski.net.Enums;
using Luski.Shared.PublicServers.V1.Enums;
namespace Luski.net.Structures.Public;
public class SocketFile
{
public required PublicServer Server { get; init; }
public required long ID { get; init; }
public required string Name { get; init; }
public required EncoderType Encoder { get; init; }
public required EncoderType NameEncoder { get; init; }
public required long Key { get; init; }
public required long NameKey { get; init; }
public required long Size { get; init; }
public async Task<Stream> GetCache(CancellationToken CancellationToken)
{
string d = Server.Storage.GetStorageDirectory(StorageDirectory.Files) + ID.ToString();
bool isc = System.IO.File.Exists(d);
if (!isc) await Server.GetFromServer($"socketfile?id={ID}", d, CancellationToken);
return Server.Storage.GetResourceStream(StorageDirectory.Files, ID.ToString());
}
}