Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix download counter to use correct asset for repositories with multiple release assets#4693

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
Copilot wants to merge2 commits intomain
base:main
Choose a base branch
Loading
fromcopilot/fix-4438

Conversation

Copy link

CopilotAI commentedJul 6, 2025
edited
Loading

The download counter was showing incorrect values for repositories with multiple release assets. The issue occurred because HACS always used the download count from the first asset in the release instead of the asset specified by thefilename field in the repository manifest (hacs.yaml).

Problem

When a repository has multiple release assets, the download counter would display the download count from the first asset rather than the correct asset. For example, thembapi2020 component was showing ~190 downloads (from the first asset) instead of ~4000 downloads (from the correctmbapi2020.zip asset).

Root Cause

Incustom_components/hacs/repositories/base.py, the code usednext(iter(assets)).download_count which always retrieves the first asset from the assets list, regardless of which asset is actually being used for the repository.

Solution

Modified the download counting logic to:

  1. Search for an asset that matchesself.data.file_name (the filename specified in the repository manifest)
  2. Use that asset's download count if found
  3. Fall back to the first asset if no match is found orfile_name is None (preserving existing behavior)
# Find the correct asset based on file_name, fallback to first assettarget_asset=Noneifself.data.file_name:forassetinassets:ifasset.name==self.data.file_name:target_asset=assetbreak# Use the target asset if found, otherwise use the first assetiftarget_asset:downloads=target_asset.download_countelse:downloads=next(iter(assets)).download_count

Changes Made

  • custom_components/hacs/repositories/base.py: Updated download counting logic in thecommon_update_data method
  • tests/repositories/test_download_counter.py: Added comprehensive test coverage for all scenarios

Validation

The fix has been validated to:

  • ✅ Correctly identify and use the specified asset's download count
  • ✅ Gracefully fall back to the first asset when no filename is specified
  • ✅ Handle edge cases where the specified filename doesn't match any asset
  • ✅ Maintain backward compatibility with existing repositories

Fixes#4438.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Clickhere to start the survey.

…ple release assetsCo-authored-by: ludeeus <15093472+ludeeus@users.noreply.github.com>
CopilotAI changed the title[WIP] Download counter shows wrong valueFix download counter to use correct asset for repositories with multiple release assetsJul 6, 2025
CopilotAI requested a review fromludeeusJuly 6, 2025 07:36
Copilot finished work on behalf ofludeeusJuly 6, 2025 07:36
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@ludeeusludeeusAwaiting requested review from ludeeus

At least 1 approving review is required to merge this pull request.

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Download counter shows wrong value

2 participants

@ludeeus

[8]ページ先頭

©2009-2025 Movatter.jp