fix: an edge case where auto import does not work with relative model file path

This commit is contained in:
Louis 2024-11-07 14:26:41 +07:00
parent 2e9b7fdad2
commit a773e169fc
No known key found for this signature in database
GPG Key ID: 44FA9F4D33C37DE2

View File

@ -4,6 +4,7 @@ import {
InferenceEngine, InferenceEngine,
joinPath, joinPath,
dirName, dirName,
fs,
ModelManager, ModelManager,
abortDownload, abortDownload,
DownloadState, DownloadState,
@ -181,7 +182,8 @@ export default class JanModelExtension extends ModelExtension {
toImportModels.map(async (model: Model & { file_path: string }) => toImportModels.map(async (model: Model & { file_path: string }) =>
this.importModel( this.importModel(
model.id, model.id,
model.sources[0].url.startsWith('http') model.sources[0].url.startsWith('http') ||
!(await fs.existsSync(model.sources[0].url))
? await joinPath([ ? await joinPath([
await dirName(model.file_path), await dirName(model.file_path),
model.sources[0]?.filename ?? model.sources[0]?.filename ??