Merge pull request #4794 from janhq/fix/appimage-could-not-load-model
fix: app image - could not load model
This commit is contained in:
commit
c000f75593
@ -4,11 +4,12 @@ import {
|
|||||||
getJanDataFolderPath,
|
getJanDataFolderPath,
|
||||||
log,
|
log,
|
||||||
} from '@janhq/core/node'
|
} from '@janhq/core/node'
|
||||||
import { mkdir, readdir, symlink } from 'fs/promises'
|
import { mkdir, readdir, symlink, cp } from 'fs/promises'
|
||||||
|
import { existsSync } from 'fs'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create symlink to each variant for the default bundled version
|
* Create symlink to each variant for the default bundled version
|
||||||
|
* If running in AppImage environment, copy files instead of creating symlinks
|
||||||
*/
|
*/
|
||||||
const symlinkEngines = async () => {
|
const symlinkEngines = async () => {
|
||||||
const sourceEnginePath = path.join(
|
const sourceEnginePath = path.join(
|
||||||
@ -23,6 +24,8 @@ const symlinkEngines = async () => {
|
|||||||
'cortex.llamacpp'
|
'cortex.llamacpp'
|
||||||
)
|
)
|
||||||
const variantFolders = await readdir(sourceEnginePath)
|
const variantFolders = await readdir(sourceEnginePath)
|
||||||
|
const isAppImage = !!process.env.APPIMAGE
|
||||||
|
|
||||||
for (const variant of variantFolders) {
|
for (const variant of variantFolders) {
|
||||||
const targetVariantPath = path.join(
|
const targetVariantPath = path.join(
|
||||||
sourceEnginePath,
|
sourceEnginePath,
|
||||||
@ -39,10 +42,25 @@ const symlinkEngines = async () => {
|
|||||||
recursive: true,
|
recursive: true,
|
||||||
}).catch((error) => log(JSON.stringify(error)))
|
}).catch((error) => log(JSON.stringify(error)))
|
||||||
|
|
||||||
await symlink(targetVariantPath, symlinkVariantPath, 'junction').catch(
|
// Skip if already exists
|
||||||
(error) => log(JSON.stringify(error))
|
if (existsSync(symlinkVariantPath)) {
|
||||||
)
|
console.log(`Target already exists: ${symlinkVariantPath}`)
|
||||||
console.log(`Symlink created: ${targetVariantPath} -> ${symlinkEnginePath}`)
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isAppImage) {
|
||||||
|
// Copy files for AppImage environments instead of symlinking
|
||||||
|
await cp(targetVariantPath, symlinkVariantPath, { recursive: true }).catch(
|
||||||
|
(error) => log(JSON.stringify(error))
|
||||||
|
)
|
||||||
|
console.log(`Files copied: ${targetVariantPath} -> ${symlinkVariantPath}`)
|
||||||
|
} else {
|
||||||
|
// Create symlink for other environments
|
||||||
|
await symlink(targetVariantPath, symlinkVariantPath, 'junction').catch(
|
||||||
|
(error) => log(JSON.stringify(error))
|
||||||
|
)
|
||||||
|
console.log(`Symlink created: ${targetVariantPath} -> ${symlinkVariantPath}`)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user