28 lines
1.1 KiB
C#
28 lines
1.1 KiB
C#
using System.IO;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using JacobTechEncryption.Enums;
|
|
using Luski.net.Enums;
|
|
|
|
namespace Luski.net.Structures.Public;
|
|
|
|
public class SocketFile
|
|
{
|
|
public required PublicServer Server { get; init; }
|
|
public required long ID { get; init; }
|
|
public required long Channel { 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) + Channel.ToString() + "-" + ID.ToString();
|
|
bool isc = System.IO.File.Exists(d);
|
|
if (!isc) await Server.GetFromServer($"socketfile?id={ID}&channel={Channel}", d, CancellationToken);
|
|
return Server.Storage.GetResourceStream(StorageDirectory.Files, Channel.ToString() + "-" + ID.ToString());
|
|
}
|
|
} |