Skip to content

Restore package icons missing from list views - #5311

Merged
Gabriel Dufresne (GabrielDuf) merged 2 commits into
mainfrom
fix/5247-package-list-icons
Aug 21, 2026
Merged

Restore package icons missing from list views#5311
Gabriel Dufresne (GabrielDuf) merged 2 commits into
mainfrom
fix/5247-package-list-icons

Conversation

@GabrielDuf

Copy link
Copy Markdown
Contributor

This pull request introduces significant improvements to the icon caching and lookup system across the package engine, UI, and supporting infrastructure. The main focus is to prevent repeated attempts to load or decode icons that have previously failed, by tracking failures and introducing a retry interval. Additionally, the changes improve cache clearing, error logging, and test coverage for these behaviors.

Icon caching and failure tracking improvements:

  • Added tracking for failed icon loads and lookups in both PackageWrapper and Package, preventing repeated attempts to load icons that have recently failed. A retry interval (default 5 minutes, test-overridable) is enforced before another attempt is made.
  • Updated cache clearing methods to also clear the failed icon tracking, ensuring that resets allow immediate retries of previously failed lookups.

Icon loading and decoding robustness:

  • Changed logic to mark icon loads as failed (instead of caching null) when decoding or retrieval fails, and to skip retries within the retry interval. Improved error logging for undecodable icons.
  • Updated file extension checks to more accurately identify known undecodable image types.

Infrastructure and test coverage:

  • Added a new test suite (PackageIconLookupTests) to verify correct retry behavior, cache clearing, and icon lookup caching, including support for overriding the retry interval in tests.

Minor corrections:

  • Fixed MIME type mappings for icon files in IconCacheEngine.cs.

Icon caching and failure tracking:

  • Added dictionaries to track failed icon loads in PackageWrapper and failed icon lookups in Package, with logic to prevent repeated attempts within a configurable interval.

Icon loading and decoding:

  • Changed icon load failure handling to mark as failed (not cache null), and improved error logging for undecodable icons.
  • Updated logic to skip known undecodable extensions.

Testing and infrastructure:

  • Added PackageIconLookupTests to verify retry, cache, and clearing behaviors, including a test-only override for the retry interval.

Other:

  • Corrected MIME type mappings for icon files.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Improves package icon recovery by replacing permanent failure caching with retryable failure tracking.

Changes:

  • Adds five-minute retry tracking across package lookup and UI decoding caches.
  • Clears lookup state during icon-cache resets and corrects icon MIME mappings.
  • Adds package-level retry and reset tests.

Reviewed changes

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

Show a summary per file
File Description
PackageIconLookupTests.cs Tests lookup retries and resets.
Package.cs Tracks failed icon lookups.
IconCacheEngine.cs Corrects ICO MIME mappings.
Interface_PViewModel.cs Resets the package icon cache.
PackageCollections.cs Tracks UI icon failures and decoding retries.
Suppressed comments (2)

src/UniGetUI.Avalonia/Models/PackageCollections.cs:115

  • Clearing these collections does not invalidate tasks already present in _inflightIconLoads. An icon load that completes after this method returns will call CacheIcon or MarkIconFailed and repopulate the just-cleared state, so resetting the cache can still leave a package suppressed for another five minutes. Cancel/drain in-flight loads or use a cache-generation token so pre-clear completions are discarded.
            _iconCache.Clear();
            _iconCacheOrder.Clear();
            _failedIcons.Clear();

src/UniGetUI.PackageEngine.PackageManagerClasses/Packages/Package.cs:405

  • GetIconUrlIfAny can still be running while this reset executes; that call may write a success or failure immediately after both dictionaries are cleared. In particular, a stale failure then defeats the reset's intended immediate retry for five more minutes. Synchronize resets with active lookups or gate writes with a generation captured before loading.
            _cachedIconPaths.Clear();
            _failedIconLookups.Clear();

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/UniGetUI.Avalonia/Models/PackageCollections.cs
Comment thread src/UniGetUI.PackageEngine.PackageManagerClasses/Packages/Package.cs Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] some package icon can not display on the main page,but it can displayed correctly on the package details page

3 participants