From 9365aa16cd432daa5646d400594aa41e23f47116 Mon Sep 17 00:00:00 2001 From: FrigaT Date: Mon, 8 Dec 2025 17:01:40 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=BE=20=D0=B2=D1=80=D0=B5=D0=BC=D0=B5=D0=BD=D0=BD=D0=BE?= =?UTF-8?q?=D0=B5=20=D0=BA=D0=BE=D0=BF=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20updater.exe?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ReleaseUpdater/ReleaseUpdaterFacade.cs | 28 +++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/ReleaseUpdater/ReleaseUpdaterFacade.cs b/ReleaseUpdater/ReleaseUpdaterFacade.cs index bedfe27..1736d7a 100644 --- a/ReleaseUpdater/ReleaseUpdaterFacade.cs +++ b/ReleaseUpdater/ReleaseUpdaterFacade.cs @@ -72,7 +72,7 @@ public static class ReleaseUpdaterFacade /// Обновление через внешний Updater.exe. /// 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 { @@ -83,13 +83,31 @@ public static class ReleaseUpdaterFacade var asset = release.Assets.FirstOrDefault(a => a.Name.EndsWith(".zip")) ?? 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 zipPath = await downloader.DownloadAssetAsync(asset.DownloadUrl, token); + var zipPath = await downloader.DownloadAssetAsync(asset.DownloadUrl, token, Path.Combine(tempUpdaterDirectory, $"updater_{tempNumber}.zip")); BeforeInstall?.Invoke(); - - if (updaterExePath == null) updaterExePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Updater.exe"); + File.Copy(updaterExePath, tempUpdaterPath); if (installPath.EndsWith("\\")) { @@ -113,7 +131,7 @@ public static class ReleaseUpdaterFacade var process = Process.Start(new ProcessStartInfo { - FileName = updaterExePath, + FileName = tempUpdaterPath, Arguments = args, UseShellExecute = true, WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory