PR: Sub Issue 8 - BlackListManager Lazy<T> + IBlackListMatcher#326
Merged
Conversation
- 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
Contributor
There was a problem hiding this comment.
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
IBlackListMatcherand refactorBlackListManagertoLazy<BlackListManager>with lock-protected mutation. - Add OSS-related
UpdateOptionsentries 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 |
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
Closes #325
Changes
Build
✅ 0 errors