Skip to content

Only use first file in compressed game when calculating hashes #2073

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

Merged
merged 1 commit into from
Jul 13, 2025

Conversation

gantoine
Copy link
Member

Description
Explain the changes or enhancements you are proposing with this pull request.

Also fixes deleting game from the homepage.

Checklist
Please check all that apply.

  • I've tested the changes locally
  • I've updated relevant comments
  • I've assigned reviewers for this PR
  • I've added unit tests that cover the changes

@gantoine gantoine requested a review from Copilot July 13, 2025 16:06
Copy link

trunk-io bot commented Jul 13, 2025

Running Code Quality on PRs by uploading data to Trunk will soon be removed. You can still run checks on your PRs using trunk-action - see the migration guide for more information.

Copy link
Contributor

@Copilot 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 ensures that only the first file in a compressed game archive is used when computing hashes, and it also fixes the deletion flow on the homepage by correctly updating the store’s continue-playing list.

  • Select and hash only the first valid file in zip, tar, and 7z archives.
  • Rename the continue-playing setter in the frontend store and update calls.
  • Update deletion dialog to remove deleted ROMs from both recent and continue-playing lists.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
frontend/src/views/Home.vue Fixed call to the renamed setContinuePlayingRoms action instead of the old setContinuePlayedRoms.
frontend/src/stores/roms.ts Renamed setContinuePlayedRoms to setContinuePlayingRoms.
frontend/src/components/common/Game/Dialog/DeleteRom.vue After removing ROM(s), also filter them out of both recent and continue-playing lists.
backend/handler/scan_handler.py Switched from get_rom(rom_attrs) to lookup_rom(fs_rom["files"]).
backend/handler/metadata/hasheous_handler.py Replaced get_rom with lookup_rom(files), extracting only the first valid file’s hashes.
backend/handler/filesystem/roms_handler.py Early return/break in zip, tar, and 7z readers so only the first file is read for hashing.
Comments suppressed due to low confidence (4)

backend/handler/metadata/hasheous_handler.py:204

  • Add unit tests for lookup_rom to verify that when multiple files are provided, only the first valid file’s hashes are used in the returned HasheousRom.
    async def lookup_rom(self, files: list[RomFile]) -> HasheousRom:

frontend/src/components/common/Game/Dialog/DeleteRom.vue:76

  • Add a component/unit test for the deletion flow to assert that both recentRoms and continuePlayingRoms are correctly filtered when deleting ROMs.
      romsStore.setContinuePlayingRoms(

backend/handler/filesystem/roms_handler.py:134

  • Relying on the archive’s native order may be non-deterministic across tools. Consider sorting z.namelist() (or filtering by file extension) before picking the first entry to ensure consistent behavior.
            for file in z.namelist():

backend/handler/metadata/hasheous_handler.py:204

  • [nitpick] get_rom was replaced by lookup_rom — consider deprecating or removing the old method and updating any documentation/comments to avoid confusion.
    async def lookup_rom(self, files: list[RomFile]) -> HasheousRom:

Copy link

Test Results

168 tests  ±0   168 ✅ ±0   39s ⏱️ -1s
  1 suites ±0     0 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit 9852f1e. ± Comparison against base commit c9b09e9.

Copy link

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
7848 4961 63% 0% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
backend/handler/filesystem/roms_handler.py 42% 🟢
backend/handler/metadata/hasheous_handler.py 37% 🟢
backend/handler/scan_handler.py 68% 🟢
TOTAL 49% 🟢

updated for commit: 9852f1e by action🐍

@gantoine gantoine merged commit da35b2e into master Jul 13, 2025
10 checks passed
@gantoine gantoine deleted the 4-metadata-fixes-5 branch July 13, 2025 16:10
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.

1 participant