Add guard before checking locally installed backends
This commit is contained in:
parent
4e37c361c4
commit
a6e4f28830
@ -18,22 +18,24 @@ export async function getLocalInstalledBackends(): Promise<
|
|||||||
'llamacpp',
|
'llamacpp',
|
||||||
'backends',
|
'backends',
|
||||||
])
|
])
|
||||||
const versionDirs = await fs.readdirSync(backendsDir)
|
if (await fs.existsSync(backendsDir)) {
|
||||||
|
const versionDirs = await fs.readdirSync(backendsDir)
|
||||||
|
|
||||||
// If the folder does not exist we are done.
|
// If the folder does not exist we are done.
|
||||||
if (!versionDirs) {
|
if (!versionDirs) {
|
||||||
return local
|
return local
|
||||||
}
|
}
|
||||||
for (const version of versionDirs) {
|
for (const version of versionDirs) {
|
||||||
const versionPath = await joinPath([backendsDir, version])
|
const versionPath = await joinPath([backendsDir, version])
|
||||||
const versionName = await basename(versionPath)
|
const versionName = await basename(versionPath)
|
||||||
const backendTypes = await fs.readdirSync(versionPath)
|
const backendTypes = await fs.readdirSync(versionPath)
|
||||||
|
|
||||||
// Verify that the backend is really installed
|
// Verify that the backend is really installed
|
||||||
for (const backendType of backendTypes) {
|
for (const backendType of backendTypes) {
|
||||||
const backendName = await basename(backendType)
|
const backendName = await basename(backendType)
|
||||||
if (await isBackendInstalled(backendType, versionName)) {
|
if (await isBackendInstalled(backendType, versionName)) {
|
||||||
local.push({ version: versionName, backend: backendName })
|
local.push({ version: versionName, backend: backendName })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user