Merge pull request #3989 from janhq/fix/windows-import-name-issue

fix: Model import name and ID are incorrect on Windows
This commit is contained in:
Louis 2024-11-11 12:29:55 +07:00 committed by GitHub
commit 4cd0208bb9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 9 additions and 5 deletions

View File

@ -61,6 +61,9 @@ async function checkAndMigrateTheme(
) )
if (existingTheme) { if (existingTheme) {
const desTheme = join(janDataThemesFolder, existingTheme) const desTheme = join(janDataThemesFolder, existingTheme)
if (!lstatSync(desTheme).isDirectory()) {
return
}
console.debug('Updating theme', existingTheme) console.debug('Updating theme', existingTheme)
rmdirSync(desTheme, { recursive: true }) rmdirSync(desTheme, { recursive: true })
cpSync(sourceThemePath, join(janDataThemesFolder, sourceThemeName), { cpSync(sourceThemePath, join(janDataThemesFolder, sourceThemeName), {

View File

@ -5,11 +5,11 @@ import {
ImportingModel, ImportingModel,
LocalImportModelEvent, LocalImportModelEvent,
Model, Model,
ModelEvent,
ModelExtension, ModelExtension,
OptionType, OptionType,
events, events,
fs, fs,
baseName,
} from '@janhq/core' } from '@janhq/core'
import { atom, useSetAtom } from 'jotai' import { atom, useSetAtom } from 'jotai'
@ -61,8 +61,8 @@ const useImportModel = () => {
const importModels = useCallback( const importModels = useCallback(
(models: ImportingModel[], optionType: OptionType) => { (models: ImportingModel[], optionType: OptionType) => {
models.map((model) => { models.map(async (model) => {
const modelId = model.modelId ?? model.path.split('/').pop() const modelId = model.modelId ?? (await baseName(model.path))
if (modelId) { if (modelId) {
addDownloadingModel(modelId) addDownloadingModel(modelId)
extensionManager extensionManager

View File

@ -38,7 +38,7 @@
"react": "18.2.0", "react": "18.2.0",
"react-circular-progressbar": "^2.1.0", "react-circular-progressbar": "^2.1.0",
"react-dom": "18.2.0", "react-dom": "18.2.0",
"react-dropzone": "^14.2.3", "react-dropzone": "14.2.3",
"react-hook-form": "^7.47.0", "react-hook-form": "^7.47.0",
"react-hot-toast": "^2.4.1", "react-hot-toast": "^2.4.1",
"react-icons": "^4.12.0", "react-icons": "^4.12.0",

View File

@ -306,7 +306,8 @@ const Advanced = () => {
}) })
} }
// Stop any running model to apply the changes // Stop any running model to apply the changes
if (e.target.checked !== gpuEnabled) stopModel() if (e.target.checked !== gpuEnabled)
stopModel().then(() => window.core?.api?.relaunch())
}} }}
/> />
} }