Skip to content

PR: Sub Issue 8 - BlackListManager Lazy<T> + IBlackListMatcher#326

Merged
JusterZhu merged 2 commits into
masterfrom
feature/blacklist-refactor
May 24, 2026
Merged

PR: Sub Issue 8 - BlackListManager Lazy<T> + IBlackListMatcher#326
JusterZhu merged 2 commits into
masterfrom
feature/blacklist-refactor

Conversation

@JusterZhu
Copy link
Copy Markdown
Collaborator

Summary

Closes #325

Changes

  • Replace double-check locking with \Lazy\
  • Add \IBlackListMatcher\ interface
  • All mutation methods lock-protected for thread safety
  • Backward-compatible API

Build

✅ 0 errors

JusterZhu added 2 commits May 24, 2026 08:07
- Add UpdateOptions.OSSProvider and OSSBucketRegion
- Mark GeneralUpdateOSS, GeneralClientOSS, SilentUpdateMode as [Obsolete]
- Migration: use GeneralUpdateBootstrap with AppType.OSS or Silent=true

Closes #323
…ce, thread-safe mutations

- Replace double-check locking with Lazy<T> for singleton safety
- Add IBlackListMatcher interface for future DI integration
- All mutation methods now lock-protected
- Keep backward-compatible API

Closes #325
Copilot AI review requested due to automatic review settings May 24, 2026 00:08
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 continues the GeneralUpdate v2 refactor by introducing an IBlackListMatcher abstraction and refactoring BlackListManager initialization toward Lazy<T> for thread-safe singleton creation. It also extends UpdateOptions with new OSS-related options and marks OSS-specific bootstrap entrypoints as obsolete in favor of GeneralUpdateBootstrap with AppType=OSS.

Changes:

  • Add IBlackListMatcher and refactor BlackListManager to Lazy<BlackListManager> with lock-protected mutation.
  • Add OSS-related UpdateOptions entries and deprecate OSS bootstrap classes via [Obsolete].
  • Update blacklist matching API surface (but currently breaks backward-compatibility; see comments).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
src/c#/GeneralUpdate.Core/FileSystem/BlackListManager.cs Introduces IBlackListMatcher and refactors BlackListManager singleton + thread-safety/matching logic.
src/c#/GeneralUpdate.Core/Configuration/UpdateOptions.cs Adds OSS options and modifies Token option line (currently contains a syntax error).
src/c#/GeneralUpdate.Core/Bootstrap/GeneralUpdateOSS.cs Marks legacy OSS bootstrap entrypoint as obsolete.
src/c#/GeneralUpdate.Core/Bootstrap/GeneralClientOSS.cs Marks legacy OSS client bootstrap entrypoint as obsolete (attribute formatting issue).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +43 to +67
public IReadOnlyList<string> BlackFiles { get { lock (_lock) return _blackFiles.ToList(); } }
public IReadOnlyList<string> BlackFormats { get { lock (_lock) return _blackFormats.ToList(); } }
public IReadOnlyList<string> SkipDirectorys { get { lock (_lock) return _skipDirs.ToList(); } }

// Mutation
public void AddBlackFiles(List<string>? files)
{ if (files == null) return; lock (_lock) { foreach (var f in files) AddBlackFileLocked(f); } }
public void AddBlackFile(string file)
{ if (string.IsNullOrWhiteSpace(file)) return; lock (_lock) AddBlackFileLocked(file); }
private void AddBlackFileLocked(string file)
{ if (!_blackFiles.Contains(file)) _blackFiles.Add(file); }

public void AddBlackFormats(List<string>? formats)
{ if (formats == null) return; lock (_lock) { foreach (var f in formats) AddBlackFormatLocked(f); } }
public void AddBlackFormat(string format)
{ if (string.IsNullOrWhiteSpace(format)) return; lock (_lock) AddBlackFormatLocked(format); }
private void AddBlackFormatLocked(string format)
{ if (!_blackFormats.Contains(format)) _blackFormats.Add(format); }

public void AddSkipDirectorys(List<string>? dirs)
{ if (dirs == null) return; lock (_lock) { foreach (var d in dirs) AddSkipDirectoryLocked(d); } }
public void AddSkipDirectory(string dir)
{ if (string.IsNullOrWhiteSpace(dir)) return; lock (_lock) AddSkipDirectoryLocked(dir); }
private void AddSkipDirectoryLocked(string dir)
{ if (!_skipDirs.Contains(dir)) _skipDirs.Add(dir); }
Comment on lines +69 to +73
// Matching (read operations — no lock needed for immutable reads)
public bool IsBlacklisted(string relativeFilePath)
{
var fileName = Path.GetFileName(relativeFilePath);
var fileExtension = Path.GetExtension(relativeFilePath);
var ext = Path.GetExtension(relativeFilePath);
public static readonly UpdateOption<string?> PermissionScript = UpdateOption.ValueOf<string?>("PERMISSIONSCRIPT");
public static readonly UpdateOption<string?> Scheme = UpdateOption.ValueOf<string?>("SCHEME");
public static readonly UpdateOption<string?> Token = UpdateOption.ValueOf<string?>("TOKEN");
public static readonly UpdateOption<string?> Token = UpdateOption.ValueOf<string?("TOKEN");
namespace GeneralUpdate.Core;

public sealed class GeneralClientOSS
[Obsolete("Use GeneralUpdateBootstrap with AppType=AppType.OSS instead.")] public sealed class GeneralClientOSS
@JusterZhu JusterZhu merged commit 99229c3 into master May 24, 2026
1 check passed
@JusterZhu JusterZhu deleted the feature/blacklist-refactor branch May 24, 2026 00:13
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.

Sub Issue 8: BlackListManager refactoring — remove global singleton, add IBlackListMatcher

2 participants