Luski.Net/Luski.net/Structures/Public/SocketFile.cs

28 lines
1.0 KiB
C#
Raw Normal View History

using System.IO;
using System.Threading;
using System.Threading.Tasks;
using JacobTechEncryption.Enums;
using Luski.net.Enums;
2024-08-27 10:57:22 -04:00
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)
{
2024-03-20 23:18:34 -04:00
string d = Server.Storage.GetStorageDirectory(StorageDirectory.Files) + ID.ToString();
bool isc = System.IO.File.Exists(d);
2024-03-20 23:18:34 -04:00
if (!isc) await Server.GetFromServer($"socketfile?id={ID}", d, CancellationToken);
return Server.Storage.GetResourceStream(StorageDirectory.Files, ID.ToString());
}
}