From df47139846596f3f4c02a1dc9920373496c8ad7f Mon Sep 17 00:00:00 2001 From: Chris Sherwood Date: Mon, 8 Jun 2026 09:55:15 -0700 Subject: [PATCH] fix(content): narrow Wikipedia reconcile-skip to the managed selection file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit reconcileFromFilesystem() skipped every ZIM whose filename starts with `wikipedia_en_`, on the assumption that all such files are managed by the WikipediaSelection model. But curated category tiers ship Wikipedia-themed ZIMs (e.g. Medicine → Comprehensive includes `wikipedia_en_medicine_maxi`), so those files were skipped during reconcile and their InstalledResource rows got wiped on every restart — silently downgrading the detected tier. Skip only the single file actually tracked by WikipediaSelection, matched by exact filename instead of the `wikipedia_en_` prefix. Reimplemented in-house from @johno10661's PR #774 (which was trapped on a stale base); credit to them for the diagnosis and fix. Closes #774 --- admin/app/services/collection_manifest_service.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/admin/app/services/collection_manifest_service.ts b/admin/app/services/collection_manifest_service.ts index 2479f82..ac9f6e3 100644 --- a/admin/app/services/collection_manifest_service.ts +++ b/admin/app/services/collection_manifest_service.ts @@ -5,6 +5,7 @@ import { DateTime } from 'luxon' import { join } from 'path' import CollectionManifest from '#models/collection_manifest' import InstalledResource from '#models/installed_resource' +import WikipediaSelection from '#models/wikipedia_selection' import { QueueService } from './queue_service.js' import { RunDownloadJob } from '#jobs/run_download_job' import { zimCategoriesSpecSchema, mapsSpecSchema, wikipediaSpecSchema } from '#validators/curated_collections' @@ -284,10 +285,17 @@ export class CollectionManifestService { const seenZimIds = new Set() + // Only skip the single Wikipedia file tracked by WikipediaSelection — not every file + // starting with `wikipedia_en_`. Curated category tiers (e.g. Medicine → Comprehensive) + // ship Wikipedia-themed ZIMs like `wikipedia_en_medicine_maxi` that must reconcile + // normally; otherwise their InstalledResource row gets wiped on every restart and the + // tier detection silently downgrades. + const wikipediaSelection = await WikipediaSelection.query().first() + const managedWikipediaFilename = wikipediaSelection?.filename ?? null + for (const file of zimFiles) { console.log(`Processing ZIM file: ${file.name}`) - // Skip Wikipedia files (managed by WikipediaSelection model) - if (file.name.startsWith('wikipedia_en_')) continue + if (managedWikipediaFilename && file.name === managedWikipediaFilename) continue const parsed = CollectionManifestService.parseZimFilename(file.name) console.log(`Parsed ZIM filename:`, parsed)