refactor: Migrate to DefaultBlackListMatcher, deprecate BlackListManager#415
Merged
Conversation
Replace BlackListManager singleton with DefaultBlackListMatcher injection via StorageManager.BlackListMatcher static property. - BlackListDefaults: new static class with built-in defaults - DefaultBlackListMatcher.FromConfigInfo(): factory from GlobalConfigInfo - StorageManager.BlackListMatcher: injectable matcher, fallback to old - All call sites use GlobalConfigInfo properties directly instead of BlackListManager.Instance for accumulation + ProcessInfo building - BlackListManager marked [Obsolete] Closes #412
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors blacklist handling in GeneralUpdate.Core by shifting from the legacy mutable BlackListManager singleton to an injected IBlackListMatcher model (BlackListConfig → DefaultBlackListMatcher) wired through StorageManager.BlackListMatcher, while introducing a centralized set of default blacklist values.
Changes:
- Added
BlackListDefaultsto centralize the previously hardcoded default blacklist items. - Added
DefaultBlackListMatcher.FromConfigInfo(GlobalConfigInfo)and updated bootstrap/strategy/orchestrator paths to configureStorageManager.BlackListMatcher. - Marked
BlackListManageras obsolete and updatedStorageManager.ReadFileNodeto prefer the injected matcher with fallback for backward compatibility.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| src/c#/GeneralUpdate.Core/Strategy/ClientUpdateStrategy.cs | Switched ProcessInfo/backup configuration away from BlackListManager toward config/defaults and matcher injection. |
| src/c#/GeneralUpdate.Core/Silent/SilentPollOrchestrator.cs | Configures and uses the injected matcher + defaults during silent update preparation. |
| src/c#/GeneralUpdate.Core/FileSystem/StorageManager.cs | Introduces StorageManager.BlackListMatcher and uses it (with fallback) during file enumeration. |
| src/c#/GeneralUpdate.Core/FileSystem/DefaultBlackListMatcher.cs | Adds FromConfigInfo factory for building a matcher from GlobalConfigInfo. |
| src/c#/GeneralUpdate.Core/FileSystem/BlackListManager.cs | Marks the legacy singleton as [Obsolete]. |
| src/c#/GeneralUpdate.Core/FileSystem/BlackListDefaults.cs | New defaults container for blacklist files/formats/skip-directories. |
| src/c#/GeneralUpdate.Core/Bootstrap/GeneralUpdateBootstrap.cs | Wires blacklist defaults/matcher during environment initialization and blacklist init. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
174
to
+178
| var processInfo = ConfigurationMapper.MapToProcessInfo( | ||
| _configInfo, downloadVersions, | ||
| BlackListManager.Instance.BlackFormats.ToList(), | ||
| BlackListManager.Instance.BlackFiles.ToList(), | ||
| BlackListManager.Instance.SkipDirectorys.ToList()); | ||
| _configInfo.BlackFormats ?? BlackListDefaults.DefaultBlackFormats, | ||
| _configInfo.BlackFiles ?? BlackListDefaults.DefaultBlackFiles, | ||
| _configInfo.SkipDirectorys ?? BlackListDefaults.DefaultSkipDirectories); |
Comment on lines
256
to
+258
| GeneralTracer.Info($"ClientUpdateStrategy: backing up {_configInfo!.InstallPath} -> {_configInfo.BackupDirectory}"); | ||
| StorageManager.Backup(_configInfo.InstallPath, _configInfo.BackupDirectory, | ||
| BlackListManager.Instance.SkipDirectorys); | ||
| _configInfo.SkipDirectorys ?? BlackListDefaults.DefaultSkipDirectories); |
Comment on lines
164
to
167
| // Backup | ||
| StorageManager.Backup(_configInfo.InstallPath, _configInfo.BackupDirectory, | ||
| BlackListManager.Instance.SkipDirectorys); | ||
| _configInfo.SkipDirectorys ?? BlackListDefaults.DefaultSkipDirectories); | ||
|
|
Comment on lines
169
to
+173
| _preparedProcessInfo = ConfigurationMapper.MapToProcessInfo( | ||
| _configInfo, new List<VersionInfo>(), | ||
| BlackListManager.Instance.BlackFormats.ToList(), | ||
| BlackListManager.Instance.BlackFiles.ToList(), | ||
| BlackListManager.Instance.SkipDirectorys.ToList()); | ||
| _configInfo.BlackFormats ?? BlackListDefaults.DefaultBlackFormats, | ||
| _configInfo.BlackFiles ?? BlackListDefaults.DefaultBlackFiles, | ||
| _configInfo.SkipDirectorys ?? BlackListDefaults.DefaultSkipDirectories); |
Comment on lines
+282
to
+284
| BlackFiles = processInfo.BlackFiles ?? BlackListDefaults.DefaultBlackFiles, | ||
| BlackFormats = processInfo.BlackFileFormats ?? BlackListDefaults.DefaultBlackFormats, | ||
| SkipDirectorys = processInfo.SkipDirectorys ?? BlackListDefaults.DefaultSkipDirectories |
Comment on lines
+19
to
+22
| var cfg = new BlackListConfig( | ||
| config.BlackFiles?.Count > 0 ? config.BlackFiles : null, | ||
| config.BlackFormats?.Count > 0 ? config.BlackFormats : null, | ||
| config.SkipDirectorys?.Count > 0 ? config.SkipDirectorys : null); |
|
|
||
| /// <summary>Default blacklisted file extensions.</summary> | ||
| public static readonly List<string> DefaultBlackFormats = new() | ||
| { ".patch", ".pdb", ".rar", ".tar", ".json", Configuration.Format.ZIP }; |
Comment on lines
+9
to
+24
| public static readonly List<string> DefaultBlackFiles = new() | ||
| { | ||
| "Microsoft.Bcl.AsyncInterfaces.dll", | ||
| "System.Collections.Immutable.dll", | ||
| "System.IO.Pipelines.dll", | ||
| "System.Text.Encodings.Web.dll", | ||
| "System.Text.Json.dll" | ||
| }; | ||
|
|
||
| /// <summary>Default blacklisted file extensions.</summary> | ||
| public static readonly List<string> DefaultBlackFormats = new() | ||
| { ".patch", ".pdb", ".rar", ".tar", ".json", Configuration.Format.ZIP }; | ||
|
|
||
| /// <summary>Default skipped directory prefixes.</summary> | ||
| public static readonly List<string> DefaultSkipDirectories = new() | ||
| { "app-", "fail" }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces the mutable \BlackListManager\ singleton with immutable \BlackListConfig\ → \DefaultBlackListMatcher\ injection via \StorageManager.BlackListMatcher.
Changes
New: BlackListDefaults
Static class with built-in default values (previously hardcoded in BlackListManager constructor):
DefaultBlackListMatcher
StorageManager
Call sites updated
BlackListManager
Benefits
Closes #412