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(Zim): storage path
Jake Turner9ec514e14530
diff --git a/admin/app/services/docker_service.ts b/admin/app/services/docker_service.tsindex fbfa4aca..8054f5b9 100644--- a/admin/app/services/docker_service.ts+++ b/admin/app/services/docker_service.ts@@ -5,7 +5,8 @@ import { inject } from '@adonisjs/core'import { ServiceStatus } from '../../types/services.js'import transmit from '@adonisjs/transmit/services/main'import { doResumableDownloadWithRetry } from '../utils/downloads.js'-import path from 'path'+import { join } from 'path'+import { ZIM_STORAGE_PATH } from '../utils/fs.js'@inject()export class DockerService {@@ -16,7 +17,6 @@ export class DockerService {public static CYBERCHEF_SERVICE_NAME = 'nomad_cyberchef'public static FLATNOTES_SERVICE_NAME = 'nomad_flatnotes'public static KOLIBRI_SERVICE_NAME = 'nomad_kolibri'- public static NOMAD_STORAGE_PATH = '/storage'constructor() {this.docker = new Docker({ socketPath: '/var/run/docker.sock' })@@ -330,8 +330,8 @@ export class DockerService {**/const WIKIPEDIA_ZIM_URL ='https://github.com/Crosstalk-Solutions/project-nomad/raw/refs/heads/master/install/wikipedia_en_100_mini_2025-06.zim'- const zimPath = '/zim/wikipedia_en_100_mini_2025-06.zim'- const filepath = path.join(process.cwd(), DockerService.NOMAD_STORAGE_PATH, zimPath)+ const filename = 'wikipedia_en_100_mini_2025-06.zim'+ const filepath = join(process.cwd(), ZIM_STORAGE_PATH, filename)logger.info(`[DockerService] Kiwix Serve pre-install: Downloading ZIM file to ${filepath}`)this._broadcast(diff --git a/admin/app/services/zim_service.ts b/admin/app/services/zim_service.tsindex f3fbf4d7..6ea8d896 100644--- a/admin/app/services/zim_service.ts+++ b/admin/app/services/zim_service.ts@@ -14,6 +14,7 @@ import {ensureDirectoryExists,getFileStatsIfExists,listDirectoryContents,+ ZIM_STORAGE_PATH,} from '../utils/fs.js'import { join } from 'path'import { CuratedCollectionWithStatus, CuratedCollectionsFile } from '../../types/downloads.js'@@ -29,13 +30,10 @@ const COLLECTIONS_URL =@inject()export class ZimService {- private zimStoragePath = '/storage/zim'-constructor(private dockerService: DockerService) {}async list() {- const dirPath = join(process.cwd(), this.zimStoragePath)-+ const dirPath = join(process.cwd(), ZIM_STORAGE_PATH)await ensureDirectoryExists(dirPath)const all = await listDirectoryContents(dirPath)@@ -154,7 +152,7 @@ export class ZimService {throw new Error('Could not determine filename from URL')}- const filepath = join(process.cwd(), this.zimStoragePath, filename)+ const filepath = join(process.cwd(), ZIM_STORAGE_PATH, filename)// Dispatch a background download jobconst result = await RunDownloadJob.dispatch({@@ -207,7 +205,7 @@ export class ZimService {}downloadFilenames.push(filename)- const filepath = join(process.cwd(), this.zimStoragePath, filename)+ const filepath = join(process.cwd(), ZIM_STORAGE_PATH, filename)await RunDownloadJob.dispatch({url,@@ -286,7 +284,7 @@ export class ZimService {fileName += '.zim'}- const fullPath = join(process.cwd(), this.zimStoragePath, fileName)+ const fullPath = join(process.cwd(), ZIM_STORAGE_PATH, fileName)const exists = await getFileStatsIfExists(fullPath)if (!exists) {diff --git a/admin/app/utils/fs.ts b/admin/app/utils/fs.tsindex 6f27847b..c18ab394 100644--- a/admin/app/utils/fs.ts+++ b/admin/app/utils/fs.ts@@ -4,6 +4,8 @@ import { FileEntry } from '../../types/files.js'import { createReadStream } from 'fs'import { LSBlockDevice, NomadDiskInfoRaw } from '../../types/system.js'+export const ZIM_STORAGE_PATH = '/storage/zim'+export async function listDirectoryContents(path: string): Promise<FileEntry[]> {const entries = await readdir(path, { withFileTypes: true })const results: FileEntry[] = []