mirror of
https://github.com/Crosstalk-Solutions/project-nomad.git
synced 2026-03-28 03:29:25 +01:00
fix(Zim): storage path
This commit is contained in:
parent
f318426a57
commit
9ec514e145
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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 job
|
||||
const 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) {
|
||||
|
|
|
|||
|
|
@ -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[] = []
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user