Skip to content

refactor: Migrate to DefaultBlackListMatcher, deprecate BlackListManager#415

Merged
JusterZhu merged 1 commit into
masterfrom
issue/412-blacklist-unify
May 25, 2026
Merged

refactor: Migrate to DefaultBlackListMatcher, deprecate BlackListManager#415
JusterZhu merged 1 commit into
masterfrom
issue/412-blacklist-unify

Conversation

@JusterZhu
Copy link
Copy Markdown
Collaborator

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):

  • 5 system DLLs, 6 extensions (.patch/.pdb/etc), 2 skip dirs (app-/fail)

DefaultBlackListMatcher

  • Added \FromConfigInfo(GlobalConfigInfo)\ factory method

StorageManager

  • Added static \BlackListMatcher\ property — when set, takes precedence over \BlackListManager\
  • \ReadFileNode\ uses \BlackListMatcher ?? BlackListManager.Instance\ for backward compat

Call sites updated

  • \InitBlackList()\ in Bootstrap / ClientUpdateStrategy / SilentPollOrchestrator — builds matcher from GlobalConfigInfo
  • ProcessInfo building — reads from _configInfo.BlackFiles\ directly instead of \BlackListManager.Instance\

BlackListManager

  • Marked [Obsolete]\ with guidance to use \DefaultBlackListMatcher\

Benefits

  • Single source of truth for blacklist configuration
  • Testable: matcher can be injected in unit tests
  • No global mutable state

Closes #412

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
Copilot AI review requested due to automatic review settings May 25, 2026 11:17
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors blacklist handling in GeneralUpdate.Core by shifting from the legacy mutable BlackListManager singleton to an injected IBlackListMatcher model (BlackListConfigDefaultBlackListMatcher) wired through StorageManager.BlackListMatcher, while introducing a centralized set of default blacklist values.

Changes:

  • Added BlackListDefaults to centralize the previously hardcoded default blacklist items.
  • Added DefaultBlackListMatcher.FromConfigInfo(GlobalConfigInfo) and updated bootstrap/strategy/orchestrator paths to configure StorageManager.BlackListMatcher.
  • Marked BlackListManager as obsolete and updated StorageManager.ReadFileNode to 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" };
@JusterZhu JusterZhu merged commit d1e1083 into master May 25, 2026
4 checks passed
@JusterZhu JusterZhu deleted the issue/412-blacklist-unify branch May 25, 2026 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: Migrate to DefaultBlackListMatcher, remove BlackListManager singleton

2 participants