Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/c#/GeneralUpdate.Core/Configuration/Environments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ namespace GeneralUpdate.Core.Configuration;
/// <summary>
/// Secure IPC environment variable provider.
/// AES-encrypted temp files in a dedicated subdirectory, auto-deleted after read.
/// Encryption is delegated to <see cref="IpcEncryption"/>.
/// </summary>
public static class Environments
{
// Fixed key/IV derived from a constant — not crypto-grade, but sufficient for
// ephemeral IPC where the file lives < 1 second and is in a per-user directory.
private static readonly byte[] _aesKey = SHA256.Create()
.ComputeHash(Encoding.UTF8.GetBytes("GeneralUpdate.IPC.EnvironmentProvider.v1"));
private static readonly byte[] _aesIV = new byte[16] { 0x47, 0x55, 0x50, 0x44, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
Comment on lines +15 to 19
Expand Down
3 changes: 1 addition & 2 deletions src/c#/GeneralUpdate.Core/GeneralUpdate.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<Nullable>enable</Nullable>
<Title>GeneralUpdate.Core</Title>
<Authors>JusterZhu</Authors>
<Description>GeneralUpdate unified core �?client and upgrade bootstrap, download, pipeline, strategies, utilities.</Description>
<Description>GeneralUpdate unified core client and upgrade bootstrap, download, pipeline, strategies, utilities.</Description>
<Copyright>Copyright 2020-2026 JusterZhu</Copyright>
<PackageProjectUrl>https://github.com/GeneralLibrary/GeneralUpdate</PackageProjectUrl>
<RepositoryUrl>https://github.com/GeneralLibrary/GeneralUpdate</RepositoryUrl>
Expand All @@ -30,7 +30,6 @@
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="8.0.0" />
</ItemGroup>

<!-- net10.0: IHttpClientFactory built-in; add Http package for ServiceCollection -->
<ItemGroup Condition="'$(TargetFramework)' == 'net10.0'">
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="10.0.1" />
</ItemGroup>
Expand Down
1 change: 0 additions & 1 deletion src/c#/GeneralUpdate.Core/Ipc/IProcessInfoProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public interface IProcessInfoProvider
/// <summary>
/// AES-encrypted temporary file IPC — simplest, most reliable cross-platform approach.
/// File lives in %TEMP%/GeneralUpdate/ipc/ with a random name, auto-deleted after read.
/// Encryption is delegated to <see cref="IpcEncryption"/>.
/// </summary>
public class EncryptedFileProcessInfoProvider : IProcessInfoProvider
{
Expand Down
12 changes: 6 additions & 6 deletions src/c#/GeneralUpdate.Core/Silent/SilentPollOrchestrator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
namespace GeneralUpdate.Core.Silent;

/// <summary>
/// Silent update poll orchestrator �?periodically checks for updates,
/// Silent update poll orchestrator periodically checks for updates,
/// downloads them in the background, and optionally auto-installs.
/// Replaces the legacy <c>SilentUpdateMode</c> class.
/// </summary>
Expand Down Expand Up @@ -126,7 +126,7 @@ private async Task PrepareUpdateIfNeededAsync(CancellationToken token)
return;
}

// ══�?Hooks: allow cancellation before starting update ══�?
// ══Hooks: allow cancellation before starting update ══
var updateCtx = new UpdateContext(
_configInfo.MainAppName ?? _configInfo.AppName,
_configInfo.InstallPath,
Expand Down Expand Up @@ -173,7 +173,7 @@ private async Task PrepareUpdateIfNeededAsync(CancellationToken token)
_configInfo.SkipDirectorys ?? BlackListDefaults.DefaultSkipDirectories);
_configInfo.ProcessInfo = JsonSerializer.Serialize(_preparedProcessInfo, ProcessInfoJsonContext.Default.ProcessInfo);

// ══�?Reporter: update started ══�?
// ══Reporter: update started ══
var startTime = DateTimeOffset.UtcNow;
if (_reporter != null)
{
Expand Down Expand Up @@ -203,7 +203,7 @@ await _reporter.ReportAsync(new UpdateReport(
downloadElapsed = report.TotalDuration;
GeneralTracer.Info($"SilentPollOrchestrator: download complete. Success={downloadSuccessCount}, Failed={downloadFailedCount}");

// ══�?Hooks + Reporter: download completed ══�?
// ══Hooks + Reporter: download completed ══
if (_hooks != null)
{
try
Expand Down Expand Up @@ -268,7 +268,7 @@ await _reporter.ReportAsync(new UpdateReport(
GeneralTracer.Info("SilentPollOrchestrator: update prepared.");
Interlocked.Exchange(ref _prepared, 1);

// ══�?Hooks + Reporter: update applied ══�?
// ══Hooks + Reporter: update applied ══
if (_hooks != null)
{
try { await _hooks.OnAfterUpdateAsync(updateCtx).ConfigureAwait(false); }
Expand Down Expand Up @@ -318,7 +318,7 @@ private void OnProcessExit(object? sender, EventArgs e)
{
var updaterPath = Path.Combine(_configInfo.InstallPath, _configInfo.AppName);

// Start the upgrade process first �?it will call ReceiveAsync in its constructor.
// Start the upgrade process first it will call ReceiveAsync in its constructor.
// We then call SendAsync which creates the NamedPipe server; the upgrade's
// client connects to it. Auto-fallback (SharedMemory > EncryptedFile) handles
// timing gaps where the named pipe handshake doesn't complete in time.
Expand Down
6 changes: 3 additions & 3 deletions src/c#/GeneralUpdate.Core/Strategy/ClientUpdateStrategy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public ClientUpdateStrategy UseUpdatePrecheck(Func<UpdateInfoEventArgs, bool> fu

private async Task ExecuteWorkflowAsync()
{
// Standard mode �?silent mode is handled by GeneralUpdateBootstrap.LaunchSilentAsync().
// Standard mode silent mode is handled by GeneralUpdateBootstrap.LaunchSilentAsync().
// Runtime options (Encoding, Format, DownloadTimeOut, etc.) are already
// populated on _configInfo by Bootstrap.ApplyRuntimeOptions().
await ExecuteStandardWorkflowAsync();
Expand Down Expand Up @@ -185,7 +185,7 @@ private async Task ExecuteStandardWorkflowAsync()
new EncryptedFileProcessInfoProvider().Send(processInfo);
GeneralTracer.Info("ClientUpdateStrategy: ProcessInfo sent via encrypted file IPC.");

// Backup �?conditionally skipped when BackupEnabled is false
// Backup conditionally skipped when BackupEnabled is false
if (_configInfo.BackupEnabled != false)
{
Backup();
Expand All @@ -197,7 +197,7 @@ private async Task ExecuteStandardWorkflowAsync()

_osStrategy!.Create(_configInfo);

// Download via orchestrator �?wired with options from GlobalConfigInfo
// Download via orchestrator wired with options from GlobalConfigInfo
var orchOptions = Download.Models.DownloadOrchestratorOptions.From(_configInfo);
GeneralTracer.Info($"ClientUpdateStrategy: downloading {downloadPlan.Assets.Count} asset(s).");
if (_orchestrator != null)
Expand Down
18 changes: 9 additions & 9 deletions src/c#/GeneralUpdate.Core/Strategy/OSSUpdateStrategy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using GeneralUpdate.Core.Compress;
using GeneralUpdate.Core.Configuration;
Expand All @@ -17,11 +16,11 @@
namespace GeneralUpdate.Core.Strategy;

/// <summary>
/// OSS (Object Storage Service) update strategy �?client/upgrade split via AppType.
/// OSS (Object Storage Service) update strategy client/upgrade split via AppType.
/// <list type="bullet">
/// <item><see cref="AppType.OSSClient"/> �?downloads version config, checks for updates,
/// <item><see cref="AppType.OSSClient"/> downloads version config, checks for updates,
/// starts the upgrade process, and exits.</item>
/// <item><see cref="AppType.OSSUpgrade"/> �?reads version config, downloads packages from OSS,
/// <item><see cref="AppType.OSSUpgrade"/> reads version config, downloads packages from OSS,
/// decompresses them, starts the main app, and exits.</item>
/// </list>
Comment on lines 18 to 25
/// </summary>
Expand Down Expand Up @@ -52,7 +51,7 @@ public async Task ExecuteAsync()
if (_configInfo == null)
throw new InvalidOperationException("OSSUpdateStrategy not configured. Call Create() first.");

// Dispatch by role �?no env-var detection needed.
// Dispatch by role no env-var detection needed.
if (_role == AppType.OSSUpgrade)
{
await ExecuteUpgradeAsync();
Expand Down Expand Up @@ -241,11 +240,12 @@ private async Task DownloadAssetsAsync(List<DownloadAsset> assets)
}
else
{
using var httpClient = GeneralUpdate.Core.Network.HttpClientProvider.Shared;
using var cts = new CancellationTokenSource(
TimeSpan.FromSeconds(_configInfo?.DownloadTimeOut > 0 ? _configInfo!.DownloadTimeOut : DefaultTimeOut));
using var httpClient = new HttpClient
{
Timeout = TimeSpan.FromSeconds(_configInfo?.DownloadTimeOut > 0 ? _configInfo!.DownloadTimeOut : DefaultTimeOut)
};
var orchestrator = new DefaultDownloadOrchestrator(httpClient);
await orchestrator.ExecuteAsync(plan, _appPath, token: cts.Token).ConfigureAwait(false);
await orchestrator.ExecuteAsync(plan, _appPath).ConfigureAwait(false);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public async Task ExecuteAsync(string appPath, string patchPath)
{
if (!Directory.Exists(appPath) || !Directory.Exists(patchPath)) return;

var skipDirectory = BlackListManager.Instance.SkipDirectorys.ToList();
var skipDirectory = BlackListDefaults.DefaultSkipDirectories;
var patchFiles = StorageManager.GetAllFiles(patchPath, skipDirectory);
var oldFiles = StorageManager.GetAllFiles(appPath, skipDirectory);
HandleDeleteList(patchFiles, oldFiles);
Expand Down Expand Up @@ -128,7 +128,7 @@ await Task.Run(() =>
foreach (var file in comparisonResult.DifferentNodes)
{
var extensionName = Path.GetExtension(file.FullName);
if (BlackListManager.Instance.IsBlacklisted(extensionName)) continue;
if (BlackListDefaults.DefaultBlackFormats.Contains(extensionName)) continue;

Comment on lines 128 to 132
var targetFileName = file.FullName.Replace(patchPath, "").TrimStart(Path.DirectorySeparatorChar);
var targetPath = Path.Combine(appPath, targetFileName);
Expand Down
4 changes: 2 additions & 2 deletions src/c#/GeneralUpdate.Differential/Pipeline/DiffPipeline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public async Task DirtyAsync(
var reporter = progress ?? _progress;
if (!Directory.Exists(appPath) || !Directory.Exists(patchPath)) return;

var skipDirectory = BlackListManager.Instance.SkipDirectorys.ToList();
var skipDirectory = BlackListDefaults.DefaultSkipDirectories;
var patchFiles = StorageManager.GetAllFiles(patchPath, skipDirectory).ToList();
var oldFiles = StorageManager.GetAllFiles(appPath, skipDirectory).ToList();

Expand Down Expand Up @@ -284,7 +284,7 @@ private static Task CopyUnknownFiles(string appPath, string patchPath)
foreach (var file in comparisonResult.DifferentNodes)
{
var extensionName = Path.GetExtension(file.FullName);
if (BlackListManager.Instance.IsBlacklisted(extensionName)) continue;
if (BlackListDefaults.DefaultBlackFormats.Contains(extensionName)) continue;

var targetFileName = file.FullName.Replace(patchPath, "").TrimStart(Path.DirectorySeparatorChar);
var targetPath = Path.Combine(appPath, targetFileName);
Expand Down
13 changes: 7 additions & 6 deletions tests/CoreTest/Bootstrap/ParameterMatrixAndEventTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,25 +264,26 @@ public void Configinfo_WithBlackLists_ValidatesSuccessfully()
[Fact]
public void BlackListManager_VariousConfigurations_AcceptsAllRules()
{
var manager = BlackListManager.Instance;
var manager = new DefaultBlackListMatcher(BlackListConfig.Empty);

Assert.NotNull(manager);
Assert.NotNull(manager.BlackFiles);
Assert.NotNull(manager.BlackFormats);
Assert.NotNull(manager.SkipDirectorys);
Assert.NotNull(BlackListDefaults.DefaultBlackFiles);
Assert.NotNull(BlackListDefaults.DefaultBlackFormats);
Assert.NotNull(BlackListDefaults.DefaultSkipDirectories);
Assert.False(manager.IsBlacklisted("test.dll"));
}
Comment on lines 264 to 274

[Fact]
public void BlackListManager_EmptyLists_DoesNotThrow()
{
var manager = BlackListManager.Instance;
var manager = new DefaultBlackListMatcher(BlackListConfig.Empty);
Assert.NotNull(manager);
}

[Fact]
public void BlackListManager_NullList_DoesNotThrow()
{
var manager = BlackListManager.Instance;
var manager = new DefaultBlackListMatcher(BlackListConfig.Empty);
Assert.NotNull(manager);
}

Expand Down
Loading