8000 Calculate hashes before fetching metadata by gantoine · Pull Request #1981 · rommapp/romm · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Calculate hashes before fetching metadata #1981

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 22 commits into from
Jun 15, 2025
Merged

Conversation

gantoine
Copy link
Member
@gantoine gantoine commented Jun 13, 2025

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

This PR moves the calculation of hashes before metadata scans. While this does have an impact on performance, it's a requirement for implementing playmatch and hasheous, and brings RA matching more in line with our other matchers.

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

Copy link
trunk-io bot commented Jun 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
github-actions bot commented Jun 13, 2025

Test Results

92 tests  ±0   92 ✅ ±0   29s ⏱️ -4s
 1 suites ±0    0 💤 ±0 
 1 files   ±0    0 ❌ ±0 

Results for commit 798f1cd. ± Comparison against base commit dfcd3c8.

♻️ This comment has been updated with latest results.

Copilot

This comment was marked as outdated.

@gantoine gantoine marked this pull request as ready for review June 13, 2025 02:07
@gantoine gantoine marked this pull request as draft June 13, 2025 02:16
@gantoine gantoine requested a review from Copilot June 14, 2025 19:26
@gantoine gantoine marked this pull request as ready for review June 14, 2025 19:26
Copy link
@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 pull request adjusts the order of hash calculations so that hashes are computed before scanning metadata, while also updating and refactoring several related functions. Key changes include:

  • Moving hash calculations earlier in the scan process and updating related function signatures.
  • Renaming and refactoring functions for clarity (e.g. renaming missing_rom_files to purge_rom_files).
  • Updating file handling and response handling in tests, metadata, and filesystem modules.

Reviewed Changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.

Show a summary per file
File Description
backend/models/rom.py Modified multi-game detection comment for clarity
backend/handler/tests/test_fastapi.py Updated test parameters to align with new scan_rom function signature
backend/handler/scan_handler.py Reordered arguments and updated condition checks for metadata fetching
backend/handler/metadata/ra_handler.py Refactored _search_rom to avoid variable shadowing
backend/handler/filesystem/tests/test_fs.py Updated tests for asynchronous get_roms function
backend/handler/filesystem/roms_handler.py Updated _build_rom_file and get_rom_files to include hash info in ROM files
backend/handler/filesystem/resources_handler.py Added functions to store retroachievements badges
backend/handler/database/roms_handler.py Renamed and refactored function to purge rom files instead of marking them missing
backend/endpoints/sockets/scan.py Minor cleanups and added type: ignore in socket events
backend/adapters/services/rahasher.py Moved RA_ID_TO_SLUG import inside the function for better encapsulation
Comments suppressed due to low confidence (2)

backend/handler/metadata/ra_handler.py:193

  • [nitpick] The loop variable 'r' is not very descriptive; consider renaming it to something like 'rom_item' to improve readability.
for r in roms:

backend/handler/filesystem/roms_handler.py:317

  • [nitpick] Consider adding a docstring or inline comment that documents the structure and order of the returned tuple (rom_files, crc_hash, md5_hash, sha1_hash, ra_hash) for better clarity.
async def get_rom_files(self, rom: Rom) -> tuple[list[RomFile], str, str, str, str]:

@gantoine gantoine requested review from adamantike and zurdi15 June 15, 2025 03:58
@@ -787,16 +787,15 @@ def update_rom_file(self, id: int, data: dict, session: Session = None) -> RomFi
return session.query(RomFile).filter_by(id=id).one()

@begin_session
def missing_rom_files(
def purge_rom_files(
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this change expected, or a bad rebase after Zurdi's changes?

Copy link
Member Author

Choose a reason for hiding this comment

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

it's expected, we want to purge missing files since a) they dont have metadata and b) we can rescan to repopulate them

@gantoine gantoine merged commit 0f091d3 into master Jun 15, 2025
10 checks passed
@gantoine gantoine deleted the hash-calc-scan-refactor branch June 15, 2025 16:51
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.

2 participants
0