Skip to content

Project NOMAD is an offline-first knowledge and education server. Wikipedia, thousands of books, courses, maps, and optional local AI, all running on hardware you own with no internet required.

TypeScript

fix(maps): stop world basemap provisioning from running pmtiles extract twice

jakeaturnerbc2450879500
diff --git a/admin/app/services/map_service.ts b/admin/app/services/map_service.ts
index debc4c5a..dae68a2f 100644
--- a/admin/app/services/map_service.ts
+++ b/admin/app/services/map_service.ts
@@ -389,11 +389,7 @@ export class MapService implements IMapService {
}
async ensureBaseAssets(): Promise<boolean> {
- const exists = await this.checkBaseAssetsExist()
- if (!exists) {
- const downloaded = await this.downloadBaseAssets()
- if (!downloaded) return false
- }
+ if (!(await this.ensureBaseAssetFiles())) return false
try {
await this.ensureWorldBasemap()
@@ -426,8 +422,9 @@ export class MapService implements IMapService {
* base map" action so the one network dependency can be satisfied deliberately while online (#1030).
*/
async provisionWorldBasemap(): Promise<boolean> {
- const baseAssetsExist = await this.ensureBaseAssets()
- if (!baseAssetsExist) return false
+ // Skip ensureBaseAssets(): it runs its own swallowed ensureWorldBasemap(), so a failure there
+ // would clear the in-flight promise and the call below would launch a second extract.
+ if (!(await this.ensureBaseAssetFiles())) return false
await this.ensureWorldBasemap()
return this.checkWorldBasemapExists()
}
@@ -450,6 +447,13 @@ export class MapService implements IMapService {
return this.worldBasemapInFlight
}
+ /** Download the style/sprite/font base assets if missing. Does not touch the world basemap. */
+ private async ensureBaseAssetFiles(): Promise<boolean> {
+ const exists = await this.checkBaseAssetsExist()
+ if (exists) return true
+ return this.downloadBaseAssets()
+ }
+
private async _setupWorldBasemap(): Promise<void> {
const basePath = resolve(join(this.baseDirPath, 'pmtiles'))
const filepath = resolve(join(basePath, WORLD_BASEMAP_FILENAME))