From 1036852924a9fd01fb1d6a28a889dcbde04128c8 Mon Sep 17 00:00:00 2001 From: josc146 Date: Fri, 2 Jun 2023 23:35:33 +0800 Subject: [PATCH] add path contains space prompt and chore --- backend-golang/utils.go | 8 ++++---- frontend/src/_locales/zh-hans/main.json | 4 +++- frontend/src/pages/Configs.tsx | 12 ++++++++---- frontend/src/pages/Settings.tsx | 2 +- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/backend-golang/utils.go b/backend-golang/utils.go index 690458b..ffb967c 100644 --- a/backend-golang/utils.go +++ b/backend-golang/utils.go @@ -28,11 +28,11 @@ func Cmd(args ...string) (string, error) { return "", err } - path, err := filepath.Abs(args[0]) - if err != nil { - return "", err + for _, arg := range args { + if strings.Contains(arg, " ") && strings.Contains(cmdHelper, " ") { + return "", errors.New("path contains space") // golang bug https://github.com/golang/go/issues/17149#issuecomment-473976818 + } } - args[0] = path cmd := exec.Command(cmdHelper, args...) out, err := cmd.CombinedOutput() diff --git a/frontend/src/_locales/zh-hans/main.json b/frontend/src/_locales/zh-hans/main.json index 5334833..c90e615 100644 --- a/frontend/src/_locales/zh-hans/main.json +++ b/frontend/src/_locales/zh-hans/main.json @@ -133,5 +133,7 @@ "Advanced": "高级", "Custom Python Path": "自定义Python路径", "Custom Models Path": "自定义模型路径", - "MacOS is not supported yet, please convert manually.": "暂不支持MacOS, 请手动转换" + "MacOS is not supported yet, please convert manually.": "暂不支持MacOS, 请手动转换", + "Microsoft Visual C++ Redistributable is not installed, would you like to download it?": "微软VC++组件未安装, 是否下载?", + "Path Cannot Contain Space": "路径不能包含空格" } \ No newline at end of file diff --git a/frontend/src/pages/Configs.tsx b/frontend/src/pages/Configs.tsx index 4526c96..c22ac4d 100644 --- a/frontend/src/pages/Configs.tsx +++ b/frontend/src/pages/Configs.tsx @@ -835,9 +835,9 @@ export const Configs: FC = observer(() => { } /> { - if(commonStore.platform=="darwin"){ - toast(t("MacOS is not supported yet, please convert manually."), { type: 'info' }) - return + if (commonStore.platform == 'darwin') { + toast(t('MacOS is not supported yet, please convert manually.'), { type: 'info' }); + return; } const modelPath = `${commonStore.settings.customModelsPath}/${selectedConfig.modelParameters.modelName}`; @@ -849,7 +849,11 @@ export const Configs: FC = observer(() => { toast(`${t('Convert Success')} - ${newModelPath}`, { type: 'success' }); refreshLocalModels({ models: commonStore.modelSourceList }, false); }).catch(e => { - toast(`${t('Convert Failed')} - ${e.message || e}`, { type: 'error' }); + const errMsg = e.message || e; + if (errMsg.includes('path contains space')) + toast(`${t('Convert Failed')} - ${t('Path Cannot Contain Space')}`, { type: 'error' }); + else + toast(`${t('Convert Failed')} - ${e.message || e}`, { type: 'error' }); }); setTimeout(WindowShow, 1000); } else { diff --git a/frontend/src/pages/Settings.tsx b/frontend/src/pages/Settings.tsx index 3c781fa..db3ea75 100644 --- a/frontend/src/pages/Settings.tsx +++ b/frontend/src/pages/Settings.tsx @@ -129,7 +129,7 @@ export const Settings: FC = observer(() => { }} /> } /> } - {