Skip to content

Commit

Permalink
Patch naming
Browse files Browse the repository at this point in the history
  • Loading branch information
Borna authored and Borna committed May 21, 2024
1 parent cd35aff commit 86a7264
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions Server_base/HandleClient.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Messages;
using System.Reflection.Metadata.Ecma335;
using Messages;

namespace Server_base
{
Expand Down Expand Up @@ -64,6 +65,17 @@ private async Task ProcessClientMessage(Message message)
await server.WriteLog(ex);
}
}
private static string? GetClientPatchName(string name)
{
//TODO: optimization
//Format: 0.0.0 patch win-x64.nip
string[] strings = name.Split(' ');
if (strings.Length > 1)
{
return string.Join(' ', strings[0..1])+".nip";
}
return null;
}
private async Task ClientUpdate(Message message)
{
if (message.CV != null && message.Runtime != null)
Expand All @@ -75,8 +87,13 @@ private async Task ClientUpdate(Message message)
string? path = server.GetClientPatch(message.Runtime, message.CV);
if (path != null)
{
Messages.File file = new() { Name = Path.GetFileName(path), Content = await System.IO.File.ReadAllBytesAsync(path) };
await SendMessage(new() { CVU = server.CVU, Update = true, Data = await Processing.SerializeFile(file) });
string? name = GetClientPatchName(Path.GetFileName(path));
if (name != null)
{
Messages.File file = new() { Name = name, Content = await System.IO.File.ReadAllBytesAsync(path) };
await SendMessage(new() { CVU = server.CVU, Update = true, Data = await Processing.SerializeFile(file) });

}
}
else
{
Expand Down

0 comments on commit 86a7264

Please sign in to comment.