Throw error when invalid file

This commit is contained in:
Akarshan 2025-09-10 12:06:41 +05:30
parent 5ef9d8dfc3
commit 0eff1bfaa9
No known key found for this signature in database
GPG Key ID: D75C9634A870665F

View File

@ -1049,6 +1049,9 @@ export default class llamacpp_extension extends AIEngine {
logger.info(`Installing backend from path: ${path}`) logger.info(`Installing backend from path: ${path}`)
if ((await fs.existsSync(path)) && path.endsWith('tar.gz')) { if ((await fs.existsSync(path)) && path.endsWith('tar.gz')) {
logger.error(`Invalid path or file ${path}`)
throw new Error(`Invalid path or file ${path}`)
}
const match = re.exec(archiveName) const match = re.exec(archiveName)
if (!match) throw new Error('Failed to parse archive name') if (!match) throw new Error('Failed to parse archive name')
const [, version, backend] = match const [, version, backend] = match
@ -1080,7 +1083,6 @@ export default class llamacpp_extension extends AIEngine {
) )
} }
} }
}
override async import(modelId: string, opts: ImportOptions): Promise<void> { override async import(modelId: string, opts: ImportOptions): Promise<void> {
const isValidModelId = (id: string) => { const isValidModelId = (id: string) => {