fix: prune RPM metadata when a local file is evicted
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
This commit is contained in:
@@ -53,10 +53,20 @@ type PostUploadHook interface {
|
||||
AfterUpload(ctx context.Context, repoName, storagePath, contentHash string, blobs BlobReader, db MetadataStore)
|
||||
}
|
||||
|
||||
// PostDeleteHook lets a provider clean up derived state (e.g. RPM metadata that
|
||||
// feeds generated repodata) after a local file is removed.
|
||||
type PostDeleteHook interface {
|
||||
AfterDelete(ctx context.Context, repoName, storagePath string, db MetadataDeleter) error
|
||||
}
|
||||
|
||||
type MetadataStore interface {
|
||||
InsertRPMMetadata(ctx context.Context, meta *RPMMetadata) error
|
||||
}
|
||||
|
||||
type MetadataDeleter interface {
|
||||
DeleteRPMMetadata(ctx context.Context, repoName, filePath string) error
|
||||
}
|
||||
|
||||
type RPMMetadataReader interface {
|
||||
ListRPMMetadataEntries(ctx context.Context, repoName string) ([]RPMMetadata, error)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user