4 Commits
1.0.0 ... 1.1.0

Author SHA1 Message Date
cbfd5f8da8 Updater 2025-01-06 01:01:34 +05:00
da58c11e59 Modpack format v2 2025-01-05 22:19:56 +05:00
23ec6dd194 fabric loader descriptors support 2025-01-02 18:42:19 +05:00
679d89b4b0 removed symlink creation 2024-12-31 22:49:06 +05:00
17 changed files with 328 additions and 167 deletions

View File

@@ -1,5 +1,6 @@
using Mlaumcherb.Client.Avalonia.зримое;
using Mlaumcherb.Client.Avalonia.классы;
using Mlaumcherb.Client.Avalonia.сеть.Update;
using Mlaumcherb.Client.Avalonia.холопы;
namespace Mlaumcherb.Client.Avalonia;
@@ -26,6 +27,13 @@ public record Config
new() { name = "Mojang", url = "https://piston-meta.mojang.com/mc/game/version_manifest_v2.json" },
];
public UpdateHelper.GiteaConfig gitea { get; set; } = new UpdateHelper.GiteaConfig
{
serverUrl = "https://timerix.ddns.net:3322",
user = "Timerix",
repo = "mlaumcherb",
};
[JsonIgnore] private static IOPath _filePath = "млаумчерб.json";

View File

@@ -1,5 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>1.1.0</Version>
<OutputType Condition="'$(Configuration)' == 'Debug'">Exe</OutputType>
<OutputType Condition="'$(Configuration)' != 'Debug'">WinExe</OutputType>
<TargetFramework>net8.0</TargetFramework>
@@ -18,12 +19,12 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="11.2.0" />
<PackageReference Include="Avalonia.Desktop" Version="11.2.0" />
<PackageReference Include="Avalonia.Themes.Simple" Version="11.2.0" />
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.2.0" />
<PackageReference Include="Avalonia.Labs.Gif" Version="11.2.0" />
<PackageReference Include="CliWrap" Version="3.6.7" />
<PackageReference Include="Avalonia" Version="11.2.*" />
<PackageReference Include="Avalonia.Desktop" Version="11.2.*" />
<PackageReference Include="Avalonia.Themes.Simple" Version="11.2.*" />
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.2.*" />
<PackageReference Include="Avalonia.Labs.Gif" Version="11.2.*" />
<PackageReference Include="CliWrap" Version="3.7.0" />
<PackageReference Include="DTLib" Version="1.6.1" />
<PackageReference Include="LZMA-SDK" Version="22.1.1" />
<PackageReference Include="MessageBox.Avalonia" Version="3.2.0" />
@@ -35,4 +36,8 @@
<EmbeddedResource Include="встроенное\**" />
</ItemGroup>
<ItemGroup>
<Folder Include="Gitea\" />
</ItemGroup>
</Project>

View File

@@ -2,6 +2,9 @@ using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
using Mlaumcherb.Client.Avalonia.классы;
using Mlaumcherb.Client.Avalonia.сеть;
using Mlaumcherb.Client.Avalonia.сеть.Update;
using Mlaumcherb.Client.Avalonia.холопы;
namespace Mlaumcherb.Client.Avalonia.зримое;
@@ -18,6 +21,8 @@ public class LauncherApp : Application
Logger.DebugLogEnabled = Config.debug;
AvaloniaXamlLoader.Load(this);
Update();
// some file required by forge installer
if (!File.Exists("launcher_profiles.json"))
{
@@ -27,6 +32,27 @@ public class LauncherApp : Application
InstalledVersionCatalog = InstalledVersionCatalog.Load();
}
private async void Update()
{
try
{
Logger.LogInfo(nameof(LauncherApp), "checking for updates...");
var upd = new UpdateHelper(Config.gitea);
upd.DeleteBackupFiles();
if (await upd.IsUpdateAvailable())
{
Logger.LogInfo(nameof(LauncherApp), "downloading update...");
await upd.UpdateSelf();
Logger.LogInfo(nameof(LauncherApp), "restarting...");
upd.RestartSelf();
}
}
catch (Exception e)
{
ErrorHelper.ShowMessageBox(nameof(LauncherApp), e);
}
}
public override void OnFrameworkInitializationCompleted()
{
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)

View File

@@ -178,6 +178,7 @@
<Button Classes="menu_button button_no_border" Click="ОткрытьФайлЛогов">лог-файл</Button>
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<TextBlock Name="LauncherVersionTextBox"/>
<Button Classes="menu_button button_no_border" Click="ОткрытьРепозиторий">исходный код</Button>
<gif:GifImage
Width="30" Height="30" Stretch="Uniform"

View File

@@ -1,3 +1,4 @@
using System.Reflection;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Data;
@@ -70,6 +71,7 @@ public partial class MainWindow : Window
try
{
LauncherApp.Logger.OnLogMessage += GuiLogMessage;
LauncherVersionTextBox.Text = $"v {Assembly.GetExecutingAssembly().GetName().Version}";
PlayerName = LauncherApp.Config.player_name;
MemoryLimit = LauncherApp.Config.max_memory;

View File

@@ -67,7 +67,7 @@ public class Library
public List<Rule>? rules { get; set; }
public Natives? natives { get; set; }
public Extract? extract { get; set; }
[JsonRequired] public LibraryDownloads downloads { get; set; } = null!;
public LibraryDownloads? downloads { get; set; }
}
public class AssetIndexProperties

View File

@@ -81,8 +81,8 @@ public class InstalledGameVersionProps : IComparable<InstalledGameVersionProps>,
new JsonMergeSettings { MergeArrayHandling = MergeArrayHandling.Concat });
descriptorRaw = parentDescriptorRaw;
// removing dependency
descriptorRaw.Remove("inheritsFrom");
File.WriteAllText(DescriptorPath, descriptorRaw.ToString());
// descriptorRaw.Remove("inheritsFrom");
// File.WriteAllText(DescriptorPath, descriptorRaw.ToString());
}
var descriptor = descriptorRaw.ToObject<GameVersionDescriptor>()

View File

@@ -7,13 +7,28 @@ public class Libraries
{
private static readonly string[] enabled_features = [];
public record JarLib(string name, IOPath jarFilePath, Artifact artifact);
public record NativeLib(string name, IOPath jarFilePath, Artifact artifact, Extract? extractionOptions)
public record JarLib(string name, IOPath jarFilePath, Artifact? artifact);
public record NativeLib(string name, IOPath jarFilePath, Artifact? artifact, Extract? extractionOptions)
: JarLib(name, jarFilePath, artifact);
public IReadOnlyCollection<JarLib> Libs { get; }
private IOPath GetJarFilePath(Artifact artifact)
public static IOPath GetPathFromMavenName(string mavenName, string ext = "jar")
{
int sep_0 = mavenName.IndexOf(':');
if (sep_0 == -1)
throw new ArgumentException($"Invalid maven name: {mavenName}");
int sep_1 = mavenName.IndexOf(':', sep_0 + 1);
if (sep_1 == -1)
throw new ArgumentException($"Invalid maven name: {mavenName}");
var package = mavenName.Substring(0, sep_0).Replace('.', '/');
var artifact = mavenName.Substring(sep_0 + 1, sep_1 - sep_0 - 1);
var version = mavenName.Substring(sep_1 + 1);
string file_name = $"{artifact}-{version}.{ext}";
return Path.Concat(PathHelper.GetLibrariesDir(), package, artifact, version, file_name);
}
private static IOPath GetPathFromArtifact(Artifact artifact)
{
string relativePath;
if (!string.IsNullOrEmpty(artifact.path))
@@ -60,26 +75,30 @@ public class Libraries
}
Artifact artifact = null!;
if(l.downloads.classifiers != null && !l.downloads.classifiers.TryGetValue(nativesKey, out artifact!))
if(l.downloads?.classifiers != null && !l.downloads.classifiers.TryGetValue(nativesKey, out artifact!))
throw new Exception($"can't find artifact for '{l.name}' with nativesKey '{nativesKey}'");
// skipping duplicates (WHO THE HELL CREATES THIS DISCRIPTORS AAAAAAAAA)
if(!libHashes.Add(artifact.sha1))
continue;
libs.Add(new NativeLib(l.name, GetJarFilePath(artifact), artifact, l.extract));
libs.Add(new NativeLib(l.name, GetPathFromArtifact(artifact), artifact, l.extract));
}
else
{
Artifact? artifact = l.downloads?.artifact;
if (artifact is null)
{
libs.Add(new JarLib(l.name, GetPathFromMavenName(l.name), artifact));
}
else
{
Artifact? artifact = l.downloads.artifact;
if (artifact == null)
throw new NullReferenceException($"artifact for '{l.name}' is null");
// skipping duplicates
if (!libHashes.Add(artifact.sha1))
continue;
libs.Add(new JarLib(l.name, GetJarFilePath(artifact), artifact));
libs.Add(new JarLib(l.name, GetPathFromArtifact(artifact), artifact));
}
}
}

View File

@@ -1,49 +0,0 @@
using Mlaumcherb.Client.Avalonia.холопы;
namespace Mlaumcherb.Client.Avalonia.классы;
public class MyModpackRemoteProps
{
[JsonRequired] public int format_version { get; set; }
[JsonRequired] public Artifact artifact { get; set; } = null!;
}
public class MyModpackV1
{
// 1
[JsonRequired] public int format_version { get; set; }
[JsonRequired] public string name { get; set; } = "";
// zip archive with all files
[JsonRequired] public Artifact zip { get; set; } = null!;
/// relative_path, hash
// ReSharper disable once CollectionNeverUpdated.Global
[JsonRequired] public Dictionary<string, FileProps> files { get; set; } = new();
public class FileProps
{
[JsonRequired] public string sha1 { get; set; } = "";
// disable hash validation, allowing users to edit this file
public bool allow_edit { get; set; }
// don't re-download file if it was deleted by user
public bool optional { get; set; }
}
public bool CheckFiles(IOPath basedir, bool checkHashes, bool downloadOptionalFiles, HashSet<IOPath> unmatchedFilesLocalPaths)
{
foreach (var p in files)
{
if(!downloadOptionalFiles && p.Value.optional)
continue;
var localPath = new IOPath(p.Key);
var realPath = Path.Concat(basedir, localPath);
if (!HashHelper.CheckFileSHA1(realPath, p.Value.sha1, checkHashes && !p.Value.allow_edit))
{
unmatchedFilesLocalPaths.Add(localPath);
}
}
return unmatchedFilesLocalPaths.Count == 0;
}
}

View File

@@ -0,0 +1,7 @@
namespace Mlaumcherb.Client.Avalonia.классы;
public class MyModpackRemoteProps
{
[JsonRequired] public int format_version { get; set; }
[JsonRequired] public Artifact artifact { get; set; } = null!;
}

View File

@@ -0,0 +1,47 @@
using Mlaumcherb.Client.Avalonia.холопы;
namespace Mlaumcherb.Client.Avalonia.классы;
public class MyModpackV2
{
// 2
[JsonRequired] public int format_version { get; set; }
[JsonRequired] public string name { get; set; } = "";
/// relative_path, props
// ReSharper disable once CollectionNeverUpdated.Global
[JsonRequired] public Dictionary<string, FileProps> files { get; set; } = new();
public class FileProps
{
[JsonRequired] public Artifact artifact { get; set; } = null!;
// disable hash validation, allowing users to edit this file
public bool allow_edit { get; set; }
// don't re-download file if it was deleted by user
public bool optional { get; set; }
}
public record FileCheckResult(FileProps props, IOPath relativePath, IOPath absolutePath);
public List<FileCheckResult> CheckFiles(IOPath basedir, bool checkHashes, bool downloadOptionalFiles)
{
List<FileCheckResult> unmatchedFiles = new();
IOPath launcherRoot = PathHelper.GetRootFullPath();
foreach (var p in files)
{
if(!downloadOptionalFiles && p.Value.optional)
continue;
IOPath relativePath = new IOPath(p.Key);
// libraries can be in modpacks, they are placed in global libraries directory
var absolutePath = Path.Concat(relativePath.StartsWith("libraries")
? launcherRoot : basedir, relativePath);
if (!HashHelper.CheckFileSHA1(absolutePath, p.Value.artifact.sha1, checkHashes && !p.Value.allow_edit))
{
unmatchedFiles.Add(new FileCheckResult(p.Value, relativePath, absolutePath));
}
}
return unmatchedFiles;
}
}

View File

@@ -42,7 +42,7 @@ public class LibrariesDownloadTaskFactory : INetworkTaskFactory
foreach (var l in _libraries.Libs)
{
if (!HashHelper.CheckFileSHA1(l.jarFilePath, l.artifact.sha1, checkHashes))
if (!HashHelper.CheckFileSHA1(l.jarFilePath, l.artifact?.sha1, checkHashes))
{
_libsToDownload.Add(l);
}
@@ -60,7 +60,7 @@ public class LibrariesDownloadTaskFactory : INetworkTaskFactory
{
long total = 0;
foreach (var l in _libsToDownload)
total += l.artifact.size;
total += l.artifact?.size ?? 0;
return total;
}
@@ -76,7 +76,7 @@ public class LibrariesDownloadTaskFactory : INetworkTaskFactory
await Parallel.ForEachAsync(_libsToDownload, opt, async (l, _ct) =>
{
LauncherApp.Logger.LogDebug(nameof(NetworkHelper), $"downloading library '{l.name}' to '{l.jarFilePath}'");
if(string.IsNullOrEmpty(l.artifact.url))
if(string.IsNullOrEmpty(l.artifact?.url))
throw new Exception($"library '{l.name}' doesn't have a url to download");
await DownloadFile(l.artifact.url, l.jarFilePath, _ct, pr.AddBytesCount);
if (l is Libraries.NativeLib n)

View File

@@ -1,113 +1,25 @@
using System.IO.Compression;
using Mlaumcherb.Client.Avalonia.зримое;
using Mlaumcherb.Client.Avalonia.классы;
using Mlaumcherb.Client.Avalonia.холопы;
using Mlaumcherb.Client.Avalonia.классы;
namespace Mlaumcherb.Client.Avalonia.сеть.TaskFactories;
public class ModpackDownloadTaskFactory : INetworkTaskFactory
{
INetworkTaskFactory _implementationVersion;
private GameVersionDescriptor _descriptor;
public ModpackDownloadTaskFactory(GameVersionDescriptor descriptor)
{
if(descriptor.modpack is null)
throw new ArgumentNullException(nameof(descriptor.modpack));
_descriptor = descriptor;
_implementationVersion = descriptor.modpack.format_version switch
{
1 => new MyModpackV1DownloadTaskFactory(descriptor),
2 => new MyModpackV2DownloadTaskFactory(descriptor),
_ => throw new Exception($"Unknown Modpack format_version: {descriptor.modpack.format_version}")
};
}
public Task<NetworkTask?> CreateAsync(bool checkHashes)
{
// Modpacks can include libraries.
// This libraries are downloaded in launcher_dir/libraries through symbolic link.
var localLibsDir = Path.Concat(PathHelper.GetVersionDir(_descriptor.id), "libraries");
var globalLibsDir = PathHelper.GetLibrariesDir();
var dirInfo = new DirectoryInfo(localLibsDir.ToString());
// delete dir if it isn't symlink
if(dirInfo.Exists && dirInfo.LinkTarget is null)
dirInfo.Delete(true);
if (!dirInfo.Exists)
{
LauncherApp.Logger.LogInfo(nameof(ModpackDownloadTaskFactory),
$"Creating symbolic link '{localLibsDir}' -> '{globalLibsDir}'");
dirInfo.CreateAsSymbolicLink(globalLibsDir.ToString());
}
return _implementationVersion.CreateAsync(checkHashes);
}
}
public class MyModpackV1DownloadTaskFactory : INetworkTaskFactory
{
private readonly GameVersionDescriptor _descriptor;
private IOPath _modpackDescriptorPath;
private IOPath _versionDir;
private MyModpackV1? _modpack;
private HashSet<IOPath> _filesToDosnload = new();
public MyModpackV1DownloadTaskFactory(GameVersionDescriptor descriptor)
{
_descriptor = descriptor;
_modpackDescriptorPath = PathHelper.GetModpackDescriptorPath(_descriptor.id);
_versionDir = PathHelper.GetVersionDir(_descriptor.id);
}
public async Task<NetworkTask?> CreateAsync(bool checkHashes)
{
if(_descriptor.modpack is null)
throw new ArgumentNullException(nameof(_descriptor.modpack));
(_modpack, bool didDownloadModpackDescriptor) = await NetworkHelper.ReadOrDownloadAndDeserialize<MyModpackV1>(
_modpackDescriptorPath,
_descriptor.modpack.artifact.url,
_descriptor.modpack.artifact.sha1,
checkHashes);
if (_modpack.format_version != _descriptor.modpack.format_version)
throw new Exception($"Modpack.format_version mismatches descriptor.modpack.version: " +
$"{_modpack.format_version} != {_descriptor.modpack.format_version}");
NetworkTask? networkTask = null;
if(!_modpack.CheckFiles(_versionDir, checkHashes, didDownloadModpackDescriptor, _filesToDosnload))
{
networkTask = new NetworkTask(
$"modpack '{_descriptor.assetIndex.id}'",
_modpack.zip.size,
Download
);
}
return networkTask;
}
private async Task Download(NetworkProgressReporter pr, CancellationToken ct)
{
LauncherApp.Logger.LogInfo(nameof(NetworkHelper), $"started downloading modpack '{_modpack!.name}'");
if(string.IsNullOrEmpty(_modpack.zip.url))
throw new Exception($"modpack '{_modpack.name}' doesn't have a url to download");
var _archivePath = Path.Concat(PathHelper.GetCacheDir(), "modpacks", _modpack.name + ".zip");
await NetworkHelper.DownloadFile(_modpack.zip.url, _archivePath, ct, pr.AddBytesCount);
await using var zipf = File.OpenRead(_archivePath);
using var archive = new ZipArchive(zipf);
foreach (var entry in archive.Entries)
{
IOPath localPath = new(entry.FullName);
if(_filesToDosnload.Contains(localPath))
{
var real_path = Path.Concat(_versionDir, localPath);
Directory.Create(real_path.ParentDir());
entry.ExtractToFile(real_path.ToString(), true);
}
}
LauncherApp.Logger.LogInfo(nameof(NetworkHelper), $"finished downloading modpack '{_modpack.name}'");
}
}

View File

@@ -0,0 +1,71 @@
using System.Linq;
using Mlaumcherb.Client.Avalonia.зримое;
using Mlaumcherb.Client.Avalonia.классы;
using Mlaumcherb.Client.Avalonia.холопы;
namespace Mlaumcherb.Client.Avalonia.сеть.TaskFactories;
public class MyModpackV2DownloadTaskFactory : INetworkTaskFactory
{
private readonly GameVersionDescriptor _descriptor;
private IOPath _modpackDescriptorPath;
private IOPath _versionDir;
private MyModpackV2? _modpack;
// relative, absolute
private List<MyModpackV2.FileCheckResult> _filesToDownload = new();
public MyModpackV2DownloadTaskFactory(GameVersionDescriptor descriptor)
{
_descriptor = descriptor;
_modpackDescriptorPath = PathHelper.GetModpackDescriptorPath(_descriptor.id);
_versionDir = PathHelper.GetVersionDir(_descriptor.id);
}
public async Task<NetworkTask?> CreateAsync(bool checkHashes)
{
if(_descriptor.modpack is null)
throw new ArgumentNullException(nameof(_descriptor.modpack));
(_modpack, bool didDownloadModpackDescriptor) = await NetworkHelper.ReadOrDownloadAndDeserialize<MyModpackV2>(
_modpackDescriptorPath,
_descriptor.modpack.artifact.url,
_descriptor.modpack.artifact.sha1,
checkHashes);
if (_modpack.format_version != _descriptor.modpack.format_version)
throw new Exception($"Modpack.format_version mismatches descriptor.modpack.version: " +
$"{_modpack.format_version} != {_descriptor.modpack.format_version}");
NetworkTask? networkTask = null;
_filesToDownload = _modpack.CheckFiles(_versionDir, checkHashes, didDownloadModpackDescriptor);
if(_filesToDownload.Count > 0)
{
networkTask = new NetworkTask(
$"modpack '{_modpack.name}'",
_filesToDownload.Sum(f => f.props.artifact.size),
Download
);
}
return networkTask;
}
private async Task Download(NetworkProgressReporter pr, CancellationToken ct)
{
LauncherApp.Logger.LogInfo(nameof(NetworkHelper), $"started downloading modpack '{_modpack!.name}'");
ParallelOptions opt = new()
{
MaxDegreeOfParallelism = LauncherApp.Config.max_parallel_downloads,
CancellationToken = ct
};
await Parallel.ForEachAsync(_filesToDownload, opt, async (f, _ct) =>
{
LauncherApp.Logger.LogDebug(nameof(NetworkHelper), $"downloading file '{f.relativePath}'");
if(string.IsNullOrEmpty(f.props.artifact.url))
throw new Exception($"file '{f.relativePath}' doesn't have a url to download");
await NetworkHelper.DownloadFile(f.props.artifact.url, f.absolutePath, _ct, pr.AddBytesCount);
});
LauncherApp.Logger.LogInfo(nameof(NetworkHelper), $"finished downloading modpack '{_modpack.name}'");
}
}

View File

@@ -0,0 +1,38 @@
using System.Linq;
namespace Mlaumcherb.Client.Avalonia.сеть.Update;
public class Release
{
[JsonRequired] public int id { get; set; }
[JsonRequired] public string tag_name { get; set; } = "";
[JsonRequired] public DateTime created_at { get; set; }
// ReSharper disable once CollectionNeverUpdated.Global
public List<Asset> assets { get; set; } = new();
public class Asset
{
[JsonRequired] public int id { get; set; }
[JsonRequired] public string name { get; set; } = "";
[JsonRequired] public int size { get; set; }
[JsonRequired] public DateTime created_at { get; set; }
[JsonRequired] public string browser_download_url { get; set; } = "";
public async Task Download(IOPath localPath)
{
await NetworkHelper.DownloadFile(browser_download_url, localPath);
}
}
public Asset? FindAssetByName(string name) =>
assets.FirstOrDefault(a => a.name == name);
}
public class GiteaClient(string ServerUrl)
{
public async Task<Release> GetLatestRelease(string user, string repo)
{
string url = $"{ServerUrl}//api/v1/repos/{user}/{repo}/releases/latest";
return await NetworkHelper.DownloadStringAndDeserialize<Release>(url);
}
}

View File

@@ -0,0 +1,74 @@
using System.Diagnostics;
using System.Reflection;
namespace Mlaumcherb.Client.Avalonia.сеть.Update;
public class UpdateHelper
{
private readonly string _executableName = "млаумчерб.exe";
private readonly IOPath executablePathActual;
private readonly IOPath executablePathOld;
private readonly IOPath executablePathNew;
public class GiteaConfig
{
[JsonRequired] public required string serverUrl { get; set; }
[JsonRequired] public required string user { get; set; }
[JsonRequired] public required string repo { get; set; }
}
private GiteaConfig _giteaConfig;
public UpdateHelper(GiteaConfig giteaConfig)
{
_giteaConfig = giteaConfig;
executablePathActual = _executableName;
executablePathOld = _executableName + ".old";
executablePathNew = _executableName + ".new";
Gitea = new GiteaClient(giteaConfig.serverUrl);
}
public GiteaClient Gitea { get; }
public void DeleteBackupFiles()
{
if(File.Exists(executablePathOld))
File.Delete(executablePathOld);
}
public async Task<bool> IsUpdateAvailable()
{
var latest = await Gitea.GetLatestRelease(_giteaConfig.user, _giteaConfig.repo);
if (!Version.TryParse(latest.tag_name, out var latestVersion))
throw new Exception($"Can't parse version of latest release: {latest.tag_name}");
Version? currentVersion = Assembly.GetExecutingAssembly().GetName().Version;
if(currentVersion is null)
throw new Exception($"Can't get current version from {Assembly.GetExecutingAssembly().GetName()}");
return currentVersion < latestVersion;
}
public async Task UpdateSelf()
{
if(File.Exists(executablePathNew))
File.Delete(executablePathNew);
var latest = await Gitea.GetLatestRelease(_giteaConfig.user, _giteaConfig.repo);
var asset = latest.FindAssetByName(_executableName);
if(asset == null)
throw new Exception($"Can't find updated executable on gitea: {_executableName}");
await asset.Download(executablePathNew);
File.Move(executablePathActual, executablePathOld, true);
File.Move(executablePathNew, executablePathActual, true);
}
public void RestartSelf()
{
Process.Start(executablePathActual.ToString());
Thread.Sleep(500);
Environment.Exit(0);
}
}

View File

@@ -24,8 +24,8 @@ public static class HashHelper
if (!File.Exists(f))
return false;
if(checkHash)
return sha1 is not null && HashFileSHA1(f) == sha1;
if(checkHash && sha1 is not null)
return HashFileSHA1(f) == sha1;
return true;
}