-
-
Notifications
You must be signed in to change notification settings - Fork 397
BrowserBookmark do not use SqliteConnection pooling to avoid ObjectDisposedException #3674
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🥷 Code experts: onesounds, Yusyuriv Jack251970, onesounds have most 👩💻 activity in the files. See details
Activity based on git-commit:
Knowledge based on git-blame:
Activity based on git-commit:
Knowledge based on git-blame: To learn more about /:\ gitStream - Visit our Docs |
This comment has been minimized.
This comment has been minimized.
Be a legend 🏆 by adding a before and after screenshot of the changes you made, especially if they are around UI/UX. |
1 similar comment
Be a legend 🏆 by adding a before and after screenshot of the changes you made, especially if they are around UI/UX. |
There was a problem hiding this 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 addresses ObjectDisposedException
errors by caching the SqliteConnection
instance and deferring SqliteConnection.ClearPool
until after all operations, including file deletion.
- Introduces a
connection1
variable to hold the connection reference for pool clearing - Assigns the connection to
connection1
in the existingfinally
block before disposing - Adds a second
try
block to callClearPool(connection1)
after deleting the temporary DB
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
Plugins/Flow.Launcher.Plugin.BrowserBookmark/FirefoxBookmarkLoader.cs | Cache and defer clearing the SQLite connection pool to prevent disposed-handle errors |
Plugins/Flow.Launcher.Plugin.BrowserBookmark/ChromiumBookmarkLoader.cs | Mirror changes from Firefox loader: cache connection and clear pool post-operations |
Comments suppressed due to low confidence (1)
Plugins/Flow.Launcher.Plugin.BrowserBookmark/FirefoxBookmarkLoader.cs:146
- [nitpick] The variable name
connection1
is not descriptive. Consider renaming it to something likecachedConnection
to clarify its purpose.
SqliteConnection connection1 = null;
Plugins/Flow.Launcher.Plugin.BrowserBookmark/FirefoxBookmarkLoader.cs
Outdated
Show resolved
Hide resolved
Plugins/Flow.Launcher.Plugin.BrowserBookmark/FirefoxBookmarkLoader.cs
Outdated
Show resolved
Hide resolved
📝 WalkthroughWalkthroughThe changes refactor favicon loading in Chromium and Firefox bookmark plugins by delegating database copying, error handling, and temporary file management to a new Changes
Suggested labels
Suggested reviewers
Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
Plugins/Flow.Launcher.Plugin.BrowserBookmark/ChromiumBookmarkLoader.cs (1)
158-159
: Consider using a more descriptive variable name.The caching approach is correct for deferring pool clearing, but
connection1
could be more descriptive.Consider renaming to something more explicit:
- // Cache connection for pool clean - SqliteConnection connection1 = null; + // Cache connection for pool clearing after parallel operations + SqliteConnection poolClearConnection = null;Plugins/Flow.Launcher.Plugin.BrowserBookmark/FirefoxBookmarkLoader.cs (1)
145-146
: Consistent implementation with ChromiumBookmarkLoader.Good consistency between the two loaders. Same suggestion applies here for a more descriptive variable name.
Consider using the same naming improvement:
- // Cache connection for pool clean - SqliteConnection connection1 = null; + // Cache connection for pool clearing after parallel operations + SqliteConnection poolClearConnection = null;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
Plugins/Flow.Launcher.Plugin.BrowserBookmark/ChromiumBookmarkLoader.cs
(3 hunks)Plugins/Flow.Launcher.Plugin.BrowserBookmark/FirefoxBookmarkLoader.cs
(3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: gitStream.cm
- GitHub Check: gitStream.cm
- GitHub Check: build
🔇 Additional comments (4)
Plugins/Flow.Launcher.Plugin.BrowserBookmark/ChromiumBookmarkLoader.cs (2)
222-224
: Excellent fix for the ObjectDisposedException issue.The approach of caching a connection reference instead of calling
ClearPool
immediately in each thread's finally block correctly addresses the race condition. The race condition on the assignment itself is harmless since any connection reference will work for clearing the pool.
238-242
: Correct implementation of deferred pool clearing.The null check and single pool clearing call after all parallel operations complete is the right approach. This ensures all connections are properly closed before clearing the pool, preventing the ObjectDisposedException.
Plugins/Flow.Launcher.Plugin.BrowserBookmark/FirefoxBookmarkLoader.cs (2)
218-220
: Correct and consistent fix implementation.The connection caching approach is identical to ChromiumBookmarkLoader and correctly addresses the ObjectDisposedException. Good consistency between the two bookmark loaders.
234-238
: Properly implemented deferred pool clearing.The implementation correctly mirrors the ChromiumBookmarkLoader fix. The null check and single pool clearing call after parallel operations complete resolves the ObjectDisposedException while maintaining proper resource management.
This comment has been minimized.
This comment has been minimized.
@check-spelling-bot Report🔴 Please reviewSee the 📂 files view, the 📜action log, or 📝 job summary for details.
See ❌ Event descriptions for more information. If the flagged items are 🤯 false positivesIf items relate to a ...
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
Plugins/Flow.Launcher.Plugin.BrowserBookmark/Helper/FaviconHelper.cs (1)
68-75
: Consider enhancing SVG detection robustness.The current implementation checks for basic SVG patterns but could be more comprehensive. Consider adding checks for common SVG namespace declarations or MIME type headers.
public static bool IsSvgData(byte[] data) { if (data.Length < 5) return false; string start = System.Text.Encoding.ASCII.GetString(data, 0, Math.Min(100, data.Length)); - return start.Contains("<svg") || - (start.StartsWith("<?xml") && start.Contains("<svg")); + return start.Contains("<svg") || + start.Contains("xmlns=\"http://www.w3.org/2000/svg\"") || + (start.StartsWith("<?xml") && start.Contains("<svg")); }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
Plugins/Flow.Launcher.Plugin.BrowserBookmark/ChromiumBookmarkLoader.cs
(6 hunks)Plugins/Flow.Launcher.Plugin.BrowserBookmark/FirefoxBookmarkLoader.cs
(6 hunks)Plugins/Flow.Launcher.Plugin.BrowserBookmark/Helper/FaviconHelper.cs
(1 hunks)
🧰 Additional context used
🪛 GitHub Actions: Check Spelling
Plugins/Flow.Launcher.Plugin.BrowserBookmark/FirefoxBookmarkLoader.cs
[warning] 28-28: moz
is not a recognized word. (unrecognized-spelling)
[warning] 29-29: moz
is not a recognized word. (unrecognized-spelling)
[warning] 30-30: moz
is not a recognized word. (unrecognized-spelling)
[warning] 31-31: moz
is not a recognized word. (unrecognized-spelling)
[warning] 252-252: newblahprofile
is not a recognized word. (unrecognized-spelling)
[warning] 279-279: absolue
is not a recognized word. (unrecognized-spelling)
[warning] 279-279: absolue
is not a recognized word. (unrecognized-spelling)
[warning] 285-285: absolue
is not a recognized word. (unrecognized-spelling)
Plugins/Flow.Launcher.Plugin.BrowserBookmark/ChromiumBookmarkLoader.cs
[warning] 56-56: Favicons
is not a recognized word. (unrecognized-spelling)
[warning] 58-58: Favicons
is not a recognized word. (unrecognized-spelling)
[warning] 61-61: favicons
is not a recognized word. (unrecognized-spelling)
[warning] 63-63: Favicons
is not a recognized word. (unrecognized-spelling)
[warning] 133-133: Favicons
is not a recognized word. (unrecognized-spelling)
[warning] 140-140: favicons
is not a recognized word. (unrecognized-spelling)
[warning] 162-162: favicons
is not a recognized word. (unrecognized-spelling)
[warning] 183-183: favicons
is not a recognized word. (unrecognized-spelling)
🪛 GitHub Check: Check Spelling
Plugins/Flow.Launcher.Plugin.BrowserBookmark/ChromiumBookmarkLoader.cs
[warning] 162-162:
favicons
is not a recognized word. (unrecognized-spelling)
⏰ Context from checks skipped due to timeout of 90000ms (5)
- GitHub Check: gitStream.cm
- GitHub Check: gitStream.cm
- GitHub Check: gitStream.cm
- GitHub Check: gitStream.cm
- GitHub Check: build
🔇 Additional comments (9)
Plugins/Flow.Launcher.Plugin.BrowserBookmark/FirefoxBookmarkLoader.cs (4)
7-7
: Good addition of the helper namespace.This import enables the use of the new
FaviconHelper
class for centralized favicon operations.
122-199
: Excellent refactoring that addresses the ObjectDisposedException issue.The delegation to
FaviconHelper.LoadFaviconsFromDb
properly centralizes database copying, error handling, and cleanup operations. The use ofPooling=false
in the SQLite connection string (line 132) effectively prevents the ObjectDisposedException by eliminating the need for connection pool clearing.Key improvements:
- Eliminates duplicate code between Firefox and Chromium loaders
- Centralizes error handling and temporary file management
- Removes problematic
SqliteConnection.ClearPool
calls- Maintains the same favicon extraction logic within the lambda
170-170
: Good use of centralized SVG detection.The
FaviconHelper.IsSvgData
method provides a reusable way to detect SVG image data, improving code maintainability.
182-182
: Proper delegation of bitmap saving to helper method.Using
FaviconHelper.SaveBitmapData
ensures consistent error handling and logging across all bookmark loaders.Plugins/Flow.Launcher.Plugin.BrowserBookmark/ChromiumBookmarkLoader.cs (3)
7-7
: Consistent namespace import.Matches the Firefox loader implementation for using the new
FaviconHelper
class.
135-203
: Consistent refactoring that mirrors the Firefox loader approach.The delegation to
FaviconHelper.LoadFaviconsFromDb
follows the same pattern as the Firefox loader, ensuring consistency across browser implementations. ThePooling=false
setting (line 145) properly addresses the ObjectDisposedException issue by avoiding connection pool management altogether.The refactoring successfully:
- Eliminates code duplication with the Firefox loader
- Centralizes database file handling and error management
- Maintains the original Chromium-specific favicon extraction logic
- Removes problematic pool clearing operations
🧰 Tools
🪛 GitHub Check: Check Spelling
[warning] 183-183:
favicons
is not a recognized word. (unrecognized-spelling)
[warning] 162-162:
favicons
is not a recognized word. (unrecognized-spelling)
[warning] 140-140:
favicons
is not a recognized word. (unrecognized-spelling)🪛 GitHub Actions: Check Spelling
[warning] 140-140:
favicons
is not a recognized word. (unrecognized-spelling)
[warning] 162-162:
favicons
is not a recognized word. (unrecognized-spelling)
[warning] 183-183:
favicons
is not a recognized word. (unrecognized-spelling)
161-167
: SQL query formatting improvement.The multi-line formatting enhances readability while preserving the original query logic.
🧰 Tools
🪛 GitHub Check: Check Spelling
[warning] 162-162:
favicons
is not a recognized word. (unrecognized-spelling)🪛 GitHub Actions: Check Spelling
[warning] 162-162:
favicons
is not a recognized word. (unrecognized-spelling)Plugins/Flow.Launcher.Plugin.BrowserBookmark/Helper/FaviconHelper.cs (2)
10-54
: Well-designed method for database operations with comprehensive error handling.The
LoadFaviconsFromDb
method effectively centralizes the complex logic of copying favicon databases, executing operations on temporary copies, and ensuring proper cleanup. The nested try-catch structure (lines 21-34) appropriately handles cleanup failures without masking the original copying error.Key strengths:
- Proper temporary file management with unique GUID naming
- Comprehensive error logging for all failure scenarios
- Guaranteed cleanup even when the primary operation fails
- Clean separation of concerns through the action delegate pattern
56-66
: Simple and robust bitmap saving implementation.The method provides a clean interface for saving image data with appropriate error handling and logging.
Cache connection and clear pool after all operations to avoid ObjectDisposedException
Do not use pooling so that we do not need to clear pool to avoid ObjectDisposedException.
Follow on with #3641.
Issue: