Restore package-based link collector without blocking DLC drops
Reintroduce expandable collector packages, background metadata enrichment, filters, selection, and controlled queue transfer. Keep DLC files dropped outside the collector on the direct addContainers path without settings persistence or metadata waits. Protect collector state with stable URL identities, non-degrading metadata merges, and per-URL generations so stale enrichment responses cannot overwrite newer data or resurrect removed links.
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import type { CollectorPackage } from "../shared/collector";
|
||||
|
||||
export type CollectorEnrichmentGenerationSnapshot = Map<string, number>;
|
||||
|
||||
function collectorUrlKey(url: string): string {
|
||||
return url.trim();
|
||||
}
|
||||
|
||||
export function beginCollectorEnrichment(
|
||||
packages: CollectorPackage[],
|
||||
current: Map<string, number>
|
||||
): CollectorEnrichmentGenerationSnapshot {
|
||||
const snapshot = new Map<string, number>();
|
||||
for (const link of packages.flatMap((pkg) => pkg.links)) {
|
||||
const url = collectorUrlKey(link.url);
|
||||
const generation = (current.get(url) ?? 0) + 1;
|
||||
current.set(url, generation);
|
||||
snapshot.set(url, generation);
|
||||
}
|
||||
return snapshot;
|
||||
}
|
||||
|
||||
export function filterCurrentCollectorEnrichment(
|
||||
packages: CollectorPackage[],
|
||||
requested: CollectorEnrichmentGenerationSnapshot,
|
||||
current: ReadonlyMap<string, number>
|
||||
): CollectorPackage[] {
|
||||
return packages.flatMap((pkg) => {
|
||||
const links = pkg.links.filter((link) => {
|
||||
const url = collectorUrlKey(link.url);
|
||||
return requested.get(url) === current.get(url);
|
||||
});
|
||||
return links.length > 0 ? [{ ...pkg, links }] : [];
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user