Добавлено временное копирование updater.exe
All checks were successful
CI / build-test (push) Successful in 37s
Release / pack-and-publish (release) Successful in 39s

This commit is contained in:
2025-12-08 17:01:40 +03:00
parent 36331e8664
commit 9365aa16cd

View File

@@ -72,7 +72,7 @@ public static class ReleaseUpdaterFacade
/// Обновление через внешний Updater.exe. /// Обновление через внешний Updater.exe.
/// </summary> /// </summary>
public static async Task UpdateWithExternalAsync( public static async Task UpdateWithExternalAsync(
string apiUrl, string? token, string installPath, string appExe, string versionOrLatest = "latest", string? updaterExePath = null, bool exitCurrentApp = false) string apiUrl, string? token, string installPath, string appExe, string versionOrLatest = "latest", string? updaterExePath = null, bool exitCurrentApp = false, string? tempUpdaterDirectory = null)
{ {
try try
{ {
@@ -83,13 +83,31 @@ public static class ReleaseUpdaterFacade
var asset = release.Assets.FirstOrDefault(a => a.Name.EndsWith(".zip")) var asset = release.Assets.FirstOrDefault(a => a.Name.EndsWith(".zip"))
?? throw new Exception("No zip asset found"); ?? throw new Exception("No zip asset found");
string tempNumber = $"{Guid.NewGuid():N}";
var tempUpdaterName = $"updater_{tempNumber}.exe";
if (updaterExePath == null) updaterExePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Updater.exe");
if (string.IsNullOrWhiteSpace(tempUpdaterDirectory))
{
tempUpdaterDirectory = Path.GetDirectoryName(updaterExePath);
tempUpdaterDirectory = Path.Combine(tempUpdaterDirectory!, "tempUpdater");
}
if (!Directory.Exists(tempUpdaterDirectory))
{
Directory.CreateDirectory(tempUpdaterDirectory);
}
var tempUpdaterPath = Path.Combine(tempUpdaterDirectory, tempUpdaterName!);
var downloader = new HttpAssetDownloader(); var downloader = new HttpAssetDownloader();
var zipPath = await downloader.DownloadAssetAsync(asset.DownloadUrl, token); var zipPath = await downloader.DownloadAssetAsync(asset.DownloadUrl, token, Path.Combine(tempUpdaterDirectory, $"updater_{tempNumber}.zip"));
BeforeInstall?.Invoke(); BeforeInstall?.Invoke();
File.Copy(updaterExePath, tempUpdaterPath);
if (updaterExePath == null) updaterExePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Updater.exe");
if (installPath.EndsWith("\\")) if (installPath.EndsWith("\\"))
{ {
@@ -113,7 +131,7 @@ public static class ReleaseUpdaterFacade
var process = Process.Start(new ProcessStartInfo var process = Process.Start(new ProcessStartInfo
{ {
FileName = updaterExePath, FileName = tempUpdaterPath,
Arguments = args, Arguments = args,
UseShellExecute = true, UseShellExecute = true,
WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory