Skip to content

Commit 100cf3f

Browse files
authored
Merge pull request #422 from GeneralLibrary/cleanup/fix-ci
Fix encoding corruption from #420 and cross-project BlackListManager references
2 parents 31fa9b1 + 9acbbde commit 100cf3f

9 files changed

Lines changed: 32 additions & 32 deletions

File tree

src/c#/GeneralUpdate.Core/Configuration/Environments.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ namespace GeneralUpdate.Core.Configuration;
99
/// <summary>
1010
/// Secure IPC environment variable provider.
1111
/// AES-encrypted temp files in a dedicated subdirectory, auto-deleted after read.
12-
/// Encryption is delegated to <see cref="IpcEncryption"/>.
1312
/// </summary>
1413
public static class Environments
1514
{
15+
// Fixed key/IV derived from a constant — not crypto-grade, but sufficient for
16+
// ephemeral IPC where the file lives < 1 second and is in a per-user directory.
1617
private static readonly byte[] _aesKey = SHA256.Create()
1718
.ComputeHash(Encoding.UTF8.GetBytes("GeneralUpdate.IPC.EnvironmentProvider.v1"));
1819
private static readonly byte[] _aesIV = new byte[16] { 0x47, 0x55, 0x50, 0x44, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };

src/c#/GeneralUpdate.Core/GeneralUpdate.Core.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<Nullable>enable</Nullable>
55
<Title>GeneralUpdate.Core</Title>
66
<Authors>JusterZhu</Authors>
7-
<Description>GeneralUpdate unified core �?client and upgrade bootstrap, download, pipeline, strategies, utilities.</Description>
7+
<Description>GeneralUpdate unified core client and upgrade bootstrap, download, pipeline, strategies, utilities.</Description>
88
<Copyright>Copyright 2020-2026 JusterZhu</Copyright>
99
<PackageProjectUrl>https://github.com/GeneralLibrary/GeneralUpdate</PackageProjectUrl>
1010
<RepositoryUrl>https://github.com/GeneralLibrary/GeneralUpdate</RepositoryUrl>
@@ -30,7 +30,6 @@
3030
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="8.0.0" />
3131
</ItemGroup>
3232

33-
<!-- net10.0: IHttpClientFactory built-in; add Http package for ServiceCollection -->
3433
<ItemGroup Condition="'$(TargetFramework)' == 'net10.0'">
3534
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="10.0.1" />
3635
</ItemGroup>

src/c#/GeneralUpdate.Core/Ipc/IProcessInfoProvider.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ public interface IProcessInfoProvider
2020
/// <summary>
2121
/// AES-encrypted temporary file IPC — simplest, most reliable cross-platform approach.
2222
/// File lives in %TEMP%/GeneralUpdate/ipc/ with a random name, auto-deleted after read.
23-
/// Encryption is delegated to <see cref="IpcEncryption"/>.
2423
/// </summary>
2524
public class EncryptedFileProcessInfoProvider : IProcessInfoProvider
2625
{

src/c#/GeneralUpdate.Core/Silent/SilentPollOrchestrator.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
namespace GeneralUpdate.Core.Silent;
2424

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

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

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

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

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

321-
// Start the upgrade process first �?it will call ReceiveAsync in its constructor.
321+
// Start the upgrade process first it will call ReceiveAsync in its constructor.
322322
// We then call SendAsync which creates the NamedPipe server; the upgrade's
323323
// client connects to it. Auto-fallback (SharedMemory > EncryptedFile) handles
324324
// timing gaps where the named pipe handshake doesn't complete in time.

src/c#/GeneralUpdate.Core/Strategy/ClientUpdateStrategy.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public ClientUpdateStrategy UseUpdatePrecheck(Func<UpdateInfoEventArgs, bool> fu
8989

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

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

198198
_osStrategy!.Create(_configInfo);
199199

200-
// Download via orchestrator �?wired with options from GlobalConfigInfo
200+
// Download via orchestrator wired with options from GlobalConfigInfo
201201
var orchOptions = Download.Models.DownloadOrchestratorOptions.From(_configInfo);
202202
GeneralTracer.Info($"ClientUpdateStrategy: downloading {downloadPlan.Assets.Count} asset(s).");
203203
if (_orchestrator != null)

src/c#/GeneralUpdate.Core/Strategy/OSSUpdateStrategy.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using System.Net.Http;
77
using System.Text;
88
using System.Text.Json;
9-
using System.Threading;
109
using System.Threading.Tasks;
1110
using GeneralUpdate.Core.Compress;
1211
using GeneralUpdate.Core.Configuration;
@@ -17,11 +16,11 @@
1716
namespace GeneralUpdate.Core.Strategy;
1817

1918
/// <summary>
20-
/// OSS (Object Storage Service) update strategy �?client/upgrade split via AppType.
19+
/// OSS (Object Storage Service) update strategy client/upgrade split via AppType.
2120
/// <list type="bullet">
22-
/// <item><see cref="AppType.OSSClient"/> �?downloads version config, checks for updates,
21+
/// <item><see cref="AppType.OSSClient"/> downloads version config, checks for updates,
2322
/// starts the upgrade process, and exits.</item>
24-
/// <item><see cref="AppType.OSSUpgrade"/> �?reads version config, downloads packages from OSS,
23+
/// <item><see cref="AppType.OSSUpgrade"/> reads version config, downloads packages from OSS,
2524
/// decompresses them, starts the main app, and exits.</item>
2625
/// </list>
2726
/// </summary>
@@ -52,7 +51,7 @@ public async Task ExecuteAsync()
5251
if (_configInfo == null)
5352
throw new InvalidOperationException("OSSUpdateStrategy not configured. Call Create() first.");
5453

55-
// Dispatch by role �?no env-var detection needed.
54+
// Dispatch by role no env-var detection needed.
5655
if (_role == AppType.OSSUpgrade)
5756
{
5857
await ExecuteUpgradeAsync();
@@ -241,11 +240,12 @@ private async Task DownloadAssetsAsync(List<DownloadAsset> assets)
241240
}
242241
else
243242
{
244-
using var httpClient = GeneralUpdate.Core.Network.HttpClientProvider.Shared;
245-
using var cts = new CancellationTokenSource(
246-
TimeSpan.FromSeconds(_configInfo?.DownloadTimeOut > 0 ? _configInfo!.DownloadTimeOut : DefaultTimeOut));
243+
using var httpClient = new HttpClient
244+
{
245+
Timeout = TimeSpan.FromSeconds(_configInfo?.DownloadTimeOut > 0 ? _configInfo!.DownloadTimeOut : DefaultTimeOut)
246+
};
247247
var orchestrator = new DefaultDownloadOrchestrator(httpClient);
248-
await orchestrator.ExecuteAsync(plan, _appPath, token: cts.Token).ConfigureAwait(false);
248+
await orchestrator.ExecuteAsync(plan, _appPath).ConfigureAwait(false);
249249
}
250250
}
251251

src/c#/GeneralUpdate.Differential/Matchers/DefaultDirtyStrategy.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public async Task ExecuteAsync(string appPath, string patchPath)
5252
{
5353
if (!Directory.Exists(appPath) || !Directory.Exists(patchPath)) return;
5454

55-
var skipDirectory = BlackListManager.Instance.SkipDirectorys.ToList();
55+
var skipDirectory = BlackListDefaults.DefaultSkipDirectories;
5656
var patchFiles = StorageManager.GetAllFiles(patchPath, skipDirectory);
5757
var oldFiles = StorageManager.GetAllFiles(appPath, skipDirectory);
5858
HandleDeleteList(patchFiles, oldFiles);
@@ -128,7 +128,7 @@ await Task.Run(() =>
128128
foreach (var file in comparisonResult.DifferentNodes)
129129
{
130130
var extensionName = Path.GetExtension(file.FullName);
131-
if (BlackListManager.Instance.IsBlacklisted(extensionName)) continue;
131+
if (BlackListDefaults.DefaultBlackFormats.Contains(extensionName)) continue;
132132

133133
var targetFileName = file.FullName.Replace(patchPath, "").TrimStart(Path.DirectorySeparatorChar);
134134
var targetPath = Path.Combine(appPath, targetFileName);

src/c#/GeneralUpdate.Differential/Pipeline/DiffPipeline.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ public async Task DirtyAsync(
172172
var reporter = progress ?? _progress;
173173
if (!Directory.Exists(appPath) || !Directory.Exists(patchPath)) return;
174174

175-
var skipDirectory = BlackListManager.Instance.SkipDirectorys.ToList();
175+
var skipDirectory = BlackListDefaults.DefaultSkipDirectories;
176176
var patchFiles = StorageManager.GetAllFiles(patchPath, skipDirectory).ToList();
177177
var oldFiles = StorageManager.GetAllFiles(appPath, skipDirectory).ToList();
178178

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

289289
var targetFileName = file.FullName.Replace(patchPath, "").TrimStart(Path.DirectorySeparatorChar);
290290
var targetPath = Path.Combine(appPath, targetFileName);

tests/CoreTest/Bootstrap/ParameterMatrixAndEventTests.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -264,25 +264,26 @@ public void Configinfo_WithBlackLists_ValidatesSuccessfully()
264264
[Fact]
265265
public void BlackListManager_VariousConfigurations_AcceptsAllRules()
266266
{
267-
var manager = BlackListManager.Instance;
267+
var manager = new DefaultBlackListMatcher(BlackListConfig.Empty);
268268

269269
Assert.NotNull(manager);
270-
Assert.NotNull(manager.BlackFiles);
271-
Assert.NotNull(manager.BlackFormats);
272-
Assert.NotNull(manager.SkipDirectorys);
270+
Assert.NotNull(BlackListDefaults.DefaultBlackFiles);
271+
Assert.NotNull(BlackListDefaults.DefaultBlackFormats);
272+
Assert.NotNull(BlackListDefaults.DefaultSkipDirectories);
273+
Assert.False(manager.IsBlacklisted("test.dll"));
273274
}
274275

275276
[Fact]
276277
public void BlackListManager_EmptyLists_DoesNotThrow()
277278
{
278-
var manager = BlackListManager.Instance;
279+
var manager = new DefaultBlackListMatcher(BlackListConfig.Empty);
279280
Assert.NotNull(manager);
280281
}
281282

282283
[Fact]
283284
public void BlackListManager_NullList_DoesNotThrow()
284285
{
285-
var manager = BlackListManager.Instance;
286+
var manager = new DefaultBlackListMatcher(BlackListConfig.Empty);
286287
Assert.NotNull(manager);
287288
}
288289

0 commit comments

Comments
 (0)