28 lines
1.0 KiB
C#
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());
|
|
}
|
|
} |