Skip to content

Serve each PKG file as its own FPKGi entry - #3966

Merged
gantoine merged 3 commits into
masterfrom
fix/fpkgi-multi-file-entries
Jul 27, 2026
Merged

Serve each PKG file as its own FPKGi entry#3966
gantoine merged 3 commits into
masterfrom
fix/fpkgi-multi-file-entries

Conversation

@gantoine

@gantoine gantoine commented Jul 27, 2026

Copy link
Copy Markdown
Member

Description

The FPKGi feed emitted one entry per rom, keyed by the rom download URL (/roms/{id}/content/...). That endpoint zips multi-file roms, so a PS4 game stored as a folder (base + update + DLC) was served to FPKGi as a single zip and installation failed on the console. Single-.pkg games worked because the same endpoint serves those directly.

The feed now walks each rom's .pkg files and emits one entry per file, keyed by the per-file download URL (/roms/{id}/files/content/...), with that file's own size (FPKGi warns that an inaccurate size breaks downloads).

  • Entry names are disambiguated only when a rom holds several packages: "<Game> - Update" / "- DLC" when the file has a scanned category (from a dlc/update/… subfolder), otherwise "<Game> - <file name>". Single-package roms keep their plain name, so existing libraries look unchanged.
  • New optional ?content_type= query param (game, dlc, update, patch, demo), so each of FPKGi's CONTENT_URLS slots (games, updates, DLC, …) can point at its own RomM URL. Files without a category folder count as game. Invalid values return 400, matching the existing pkgi endpoints.
  • Packages marked missing_from_fs are skipped, so the feed no longer advertises a download that can't resolve.
  • title_id is taken from a CUSA/PPSA id in the rom or package file names when present, falling back to the generated ROMM##### id. It is resolved once per rom, so a base game and its updates/DLC stay grouped the way FPKGi searches and sorts content (and the way real PS4 dumps are numbered).
  • Drive-by: cover_url is now null when a rom has no cover, instead of a URL pointing at the site root.

Behavior note: a rom with no .pkg files (e.g. a zipped package) is no longer listed. It was listed before, but FPKGi cannot install it.

No frontend regeneration needed: the feed endpoints return a raw Response, so nothing FPKGi-related exists in frontend/src/__generated__/.

Fixes #3962

Checklist

  • 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

uv run pytest tests/endpoints/feeds.py → 13 passed. Added test_fpkgi_feed_multi_file_rom (base + update + DLC, a non-pkg file, a missing_from_fs package, shared title id, the content_type filter, and the 400 case) and extended test_fpkgi_feed to assert the per-file name, size and extracted title id.

AI assistance

This PR was written primarily by Claude Code (code, tests and description), reviewed by me before opening.

🤖 Generated with Claude Code

FPKGi installs one package per entry, but the feed served a single entry
per rom pointing at the rom download URL, which zips multi-file roms.

Each .pkg file now gets its own entry with its own size and download URL,
named after its category (or file name) when a rom holds several packages.
Adds an optional content_type filter so FPKGi's per-category content URLs
can each point at RomM.

Fixes #3962

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 27, 2026 11:59

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@greptile-apps

greptile-apps Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR changes the FPKGi feed from one ROM-level archive entry to one entry per PKG file.

  • Adds package-category filtering and disambiguated names for multi-package ROMs.
  • Uses per-file download URLs and sizes and omits ROMs without PKG files.
  • Returns a null cover URL when cover artwork is absent.
  • Adds focused feed tests and documents the endpoint behavior.

Confidence Score: 2/5

This PR is not safe to merge until package identifiers are made unique and unavailable PKG records are excluded from the feed.

Multi-package ROMs currently produce entries that FPKGi can collapse under one title ID, while stale file records can produce advertised downloads that fail.

Files Needing Attention: backend/endpoints/feeds.py, backend/tests/endpoints/feeds.py

Fix All in Claude Code

Prompt To Fix All With AI
Fix the following 2 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 2
backend/endpoints/feeds.py:651
**Duplicate package title identifiers**

When a ROM contains multiple PKG files, every emitted entry derives `title_id` solely from `rom.id`. FPKGi deduplicates aggregate content by this field, causing all but the first base, update, or DLC package for that ROM to disappear and producing incorrect installation status.

### Issue 2 of 2
backend/endpoints/feeds.py:634
**Missing packages remain advertised**

When a PKG has been removed from storage but its record is marked `missing_from_fs`, this extension-only filter still adds it to the feed. FPKGi displays the unavailable package, then installation fails because the generated download URL references a file that no longer exists.

Reviews (1): Last reviewed commit: "List each PKG file as its own FPKGi entr..." | Re-trigger Greptile

Comment thread backend/endpoints/feeds.py Outdated
Comment thread backend/endpoints/feeds.py Outdated
gantoine and others added 2 commits July 27, 2026 08:20
Files marked missing_from_fs were still advertised, so FPKGi listed a
package whose download URL no longer resolves.

Title ids now come from a CUSA/PPSA id in the rom or package file names
when present, falling back to the generated RomM id. It is resolved once
per rom so a base game and its updates/DLC stay grouped.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@gantoine
gantoine merged commit 74d1d1a into master Jul 27, 2026
11 checks passed
@gantoine
gantoine deleted the fix/fpkgi-multi-file-entries branch July 27, 2026 22:07
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.

[Bug] FPKGi endpoint serves multi-file games as a single entry — install fails for games with updates/DLC

2 participants