fix: prune RPM metadata when a local file is evicted #100

Merged
benvin merged 1 commits from benvin/rpm-metadata-evict-cleanup into master 2026-07-03 14:54:28 +10:00
Owner

Follow-up to #99.

Why

Evicting or deleting a local RPM removed the `local_files` row but left its `rpm_metadata` behind. Since generated repodata is built from `rpm_metadata`, `primary.xml` kept advertising a package that no longer exists, producing 404s for clients that tried to fetch it.

Changes

  • Add `PostDeleteHook` and `MetadataDeleter` provider interfaces (symmetric to the existing `PostUploadHook`/`MetadataStore`), plus a `DeleteRPMMetadata` DB method.
  • Implement `AfterDelete` in the RPM provider to drop the metadata row for the deleted file.
  • Route both local delete paths — the new `evictLocal` and the existing files handler's `remove` — through a shared `deleteLocalFile` helper that removes the file then runs the provider's post-delete hook. Non-RPM providers have no hook, so nothing changes for them.
  • Cover the cleanup with a dockerised test.
Follow-up to #99. ## Why Evicting or deleting a local RPM removed the \`local_files\` row but left its \`rpm_metadata\` behind. Since generated repodata is built from \`rpm_metadata\`, \`primary.xml\` kept advertising a package that no longer exists, producing 404s for clients that tried to fetch it. ## Changes - Add \`PostDeleteHook\` and \`MetadataDeleter\` provider interfaces (symmetric to the existing \`PostUploadHook\`/\`MetadataStore\`), plus a \`DeleteRPMMetadata\` DB method. - Implement \`AfterDelete\` in the RPM provider to drop the metadata row for the deleted file. - Route both local delete paths — the new \`evictLocal\` and the existing files handler's \`remove\` — through a shared \`deleteLocalFile\` helper that removes the file then runs the provider's post-delete hook. Non-RPM providers have no hook, so nothing changes for them. - Cover the cleanup with a dockerised test.
unkinben added 1 commit 2026-07-03 14:50:43 +10:00
fix: prune RPM metadata when a local file is evicted
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/test Pipeline was successful
ci/woodpecker/pr/build Pipeline was successful
808015f6bb
Evicting or deleting a local RPM removed the local_files row but left its
rpm_metadata behind, so generated repodata kept listing a package that no
longer exists. Deletes now run a provider cleanup hook symmetric to the
existing upload hook.

- add PostDeleteHook and MetadataDeleter provider interfaces, plus a
  DeleteRPMMetadata DB method
- implement AfterDelete in the RPM provider to drop the metadata row
- route both local delete paths (evictLocal and the files handler) through
  a shared deleteLocalFile helper that removes the file then runs the hook
- cover the cleanup with a dockerised test
unkinben force-pushed benvin/rpm-metadata-evict-cleanup from cbf45bfee1 to 808015f6bb 2026-07-03 14:50:43 +10:00 Compare
benvin merged commit 0ec28660ba into master 2026-07-03 14:54:28 +10:00
benvin deleted branch benvin/rpm-metadata-evict-cleanup 2026-07-03 14:54:28 +10:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: unkin/artifactapi#100