Updated to latest moonlight and mooncore version. Done refactoring to async scheme and other changes. Recreated database migrations and cleaned models
This commit is contained in:
@@ -57,18 +57,18 @@ public class HostSystemHelper
|
||||
|
||||
#region CPU Usage
|
||||
|
||||
public async Task<CpuUsageDetails> GetCpuUsage()
|
||||
public async Task<CpuUsageDetails> GetCpuUsageAsync()
|
||||
{
|
||||
var result = new CpuUsageDetails();
|
||||
var perCoreUsages = new List<double>();
|
||||
|
||||
// Initial read
|
||||
var (cpuLastStats, cpuLastSums) = await ReadAllCpuStats();
|
||||
var (cpuLastStats, cpuLastSums) = await ReadAllCpuStatsAsync();
|
||||
|
||||
await Task.Delay(1000);
|
||||
|
||||
// Second read
|
||||
var (cpuNowStats, cpuNowSums) = await ReadAllCpuStats();
|
||||
var (cpuNowStats, cpuNowSums) = await ReadAllCpuStatsAsync();
|
||||
|
||||
for (var i = 0; i < cpuNowStats.Length; i++)
|
||||
{
|
||||
@@ -94,7 +94,7 @@ public class HostSystemHelper
|
||||
return result;
|
||||
}
|
||||
|
||||
private async Task<(long[][] cpuStatsList, long[] cpuSums)> ReadAllCpuStats()
|
||||
private async Task<(long[][] cpuStatsList, long[] cpuSums)> ReadAllCpuStatsAsync()
|
||||
{
|
||||
var lines = await File.ReadAllLinesAsync("/proc/stat");
|
||||
|
||||
@@ -128,12 +128,12 @@ public class HostSystemHelper
|
||||
|
||||
#region Memory
|
||||
|
||||
public async Task ClearCachedMemory()
|
||||
public async Task ClearCachedMemoryAsync()
|
||||
{
|
||||
await File.WriteAllTextAsync("/proc/sys/vm/drop_caches", "3");
|
||||
}
|
||||
|
||||
public async Task<MemoryUsageDetails> GetMemoryUsage()
|
||||
public async Task<MemoryUsageDetails> GetMemoryUsageAsync()
|
||||
{
|
||||
var details = new MemoryUsageDetails();
|
||||
|
||||
@@ -194,7 +194,7 @@ public class HostSystemHelper
|
||||
|
||||
#region Disks
|
||||
|
||||
public async Task<DiskUsageDetails[]> GetDiskUsages()
|
||||
public async Task<DiskUsageDetails[]> GetDiskUsagesAsync()
|
||||
{
|
||||
var details = new List<DiskUsageDetails>();
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ using ICSharpCode.SharpZipLib.GZip;
|
||||
using ICSharpCode.SharpZipLib.Tar;
|
||||
using ICSharpCode.SharpZipLib.Zip;
|
||||
using Mono.Unix.Native;
|
||||
using MoonCore.Unix.Exceptions;
|
||||
using MoonCore.Unix.SecureFs;
|
||||
using MoonlightServers.DaemonShared.DaemonSide.Http.Responses.Servers;
|
||||
using MoonlightServers.DaemonShared.Enums;
|
||||
@@ -19,7 +18,7 @@ public class ServerFileSystem
|
||||
FileSystem = fileSystem;
|
||||
}
|
||||
|
||||
public Task<ServerFileSystemResponse[]> List(string inputPath)
|
||||
public Task<ServerFileSystemResponse[]> ListAsync(string inputPath)
|
||||
{
|
||||
var path = Normalize(inputPath);
|
||||
var entries = FileSystem.ReadDir(path);
|
||||
@@ -45,7 +44,7 @@ public class ServerFileSystem
|
||||
return Task.FromResult(result);
|
||||
}
|
||||
|
||||
public Task Move(string inputOldPath, string inputNewPath)
|
||||
public Task MoveAsync(string inputOldPath, string inputNewPath)
|
||||
{
|
||||
var oldPath = Normalize(inputOldPath);
|
||||
var newPath = Normalize(inputNewPath);
|
||||
@@ -55,7 +54,7 @@ public class ServerFileSystem
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task Delete(string inputPath)
|
||||
public Task DeleteAsync(string inputPath)
|
||||
{
|
||||
var path = Normalize(inputPath);
|
||||
|
||||
@@ -64,7 +63,7 @@ public class ServerFileSystem
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task Mkdir(string inputPath)
|
||||
public Task MkdirAsync(string inputPath)
|
||||
{
|
||||
var path = Normalize(inputPath);
|
||||
|
||||
@@ -73,7 +72,7 @@ public class ServerFileSystem
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task Touch(string inputPath)
|
||||
public Task TouchAsync(string inputPath)
|
||||
{
|
||||
var path = Normalize(inputPath);
|
||||
|
||||
@@ -91,7 +90,7 @@ public class ServerFileSystem
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task CreateChunk(string inputPath, long totalSize, long positionToSkip, Stream chunkStream)
|
||||
public Task CreateChunkAsync(string inputPath, long totalSize, long positionToSkip, Stream chunkStream)
|
||||
{
|
||||
var path = Normalize(inputPath);
|
||||
|
||||
@@ -114,7 +113,7 @@ public class ServerFileSystem
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task Create(string inputPath, Stream dataStream)
|
||||
public Task CreateAsync(string inputPath, Stream dataStream)
|
||||
{
|
||||
var path = Normalize(inputPath);
|
||||
|
||||
@@ -134,7 +133,7 @@ public class ServerFileSystem
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task Read(string inputPath, Func<Stream, Task> onHandle)
|
||||
public Task ReadAsync(string inputPath, Func<Stream, Task> onHandle)
|
||||
{
|
||||
var path = Normalize(inputPath);
|
||||
|
||||
@@ -149,7 +148,7 @@ public class ServerFileSystem
|
||||
|
||||
#region Compression
|
||||
|
||||
public Task Compress(string[] itemsInput, string destinationInput, CompressType type)
|
||||
public Task CompressAsync(string[] itemsInput, string destinationInput, CompressType type)
|
||||
{
|
||||
var destination = Normalize(destinationInput);
|
||||
var items = itemsInput.Select(Normalize);
|
||||
@@ -191,7 +190,7 @@ public class ServerFileSystem
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task Decompress(string pathInput, string destinationInput, CompressType type)
|
||||
public Task DecompressAsync(string pathInput, string destinationInput, CompressType type)
|
||||
{
|
||||
var path = Normalize(pathInput);
|
||||
var destination = Normalize(destinationInput);
|
||||
|
||||
@@ -17,7 +17,7 @@ public class UnsafeDockerClient
|
||||
Configuration = configuration;
|
||||
}
|
||||
|
||||
public Task<HttpClient> CreateHttpClient()
|
||||
public Task<HttpClient> CreateHttpClientAsync()
|
||||
{
|
||||
var client = new HttpClient(new SocketsHttpHandler()
|
||||
{
|
||||
@@ -35,9 +35,9 @@ public class UnsafeDockerClient
|
||||
return Task.FromResult(client);
|
||||
}
|
||||
|
||||
public async Task<DataUsageResponse> GetDataUsage()
|
||||
public async Task<DataUsageResponse> GetDataUsageAsync()
|
||||
{
|
||||
using var client = await CreateHttpClient();
|
||||
using var client = await CreateHttpClientAsync();
|
||||
var responseJson = await client.GetStringAsync("http://some.random.domain/v1.47/system/df");
|
||||
var response = JsonSerializer.Deserialize<DataUsageResponse>(responseJson)!;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user