add path contains space prompt and chore

This commit is contained in:
josc146 2023-06-02 23:35:33 +08:00
parent 2b10ccd507
commit 1036852924
4 changed files with 16 additions and 10 deletions

View File

@ -28,11 +28,11 @@ func Cmd(args ...string) (string, error) {
return "", err return "", err
} }
path, err := filepath.Abs(args[0]) for _, arg := range args {
if err != nil { if strings.Contains(arg, " ") && strings.Contains(cmdHelper, " ") {
return "", err 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...) cmd := exec.Command(cmdHelper, args...)
out, err := cmd.CombinedOutput() out, err := cmd.CombinedOutput()

View File

@ -133,5 +133,7 @@
"Advanced": "高级", "Advanced": "高级",
"Custom Python Path": "自定义Python路径", "Custom Python Path": "自定义Python路径",
"Custom Models Path": "自定义模型路径", "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": "路径不能包含空格"
} }

View File

@ -835,9 +835,9 @@ export const Configs: FC = observer(() => {
</div> </div>
} /> } />
<ToolTipButton text={t('Convert')} desc={t('Convert model with these configs')} onClick={async () => { <ToolTipButton text={t('Convert')} desc={t('Convert model with these configs')} onClick={async () => {
if(commonStore.platform=="darwin"){ if (commonStore.platform == 'darwin') {
toast(t("MacOS is not supported yet, please convert manually."), { type: 'info' }) toast(t('MacOS is not supported yet, please convert manually.'), { type: 'info' });
return return;
} }
const modelPath = `${commonStore.settings.customModelsPath}/${selectedConfig.modelParameters.modelName}`; const modelPath = `${commonStore.settings.customModelsPath}/${selectedConfig.modelParameters.modelName}`;
@ -849,7 +849,11 @@ export const Configs: FC = observer(() => {
toast(`${t('Convert Success')} - ${newModelPath}`, { type: 'success' }); toast(`${t('Convert Success')} - ${newModelPath}`, { type: 'success' });
refreshLocalModels({ models: commonStore.modelSourceList }, false); refreshLocalModels({ models: commonStore.modelSourceList }, false);
}).catch(e => { }).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); setTimeout(WindowShow, 1000);
} else { } else {

View File

@ -129,7 +129,7 @@ export const Settings: FC = observer(() => {
}} /> }} />
} /> } />
} }
<Labeled label={t('Custom Python Path')} <Labeled label={t('Custom Python Path')} // if set, will not use precompiled cuda kernel
content={ content={
<Input className="grow" placeholder="./py310/python" value={commonStore.settings.customPythonPath} <Input className="grow" placeholder="./py310/python" value={commonStore.settings.customPythonPath}
onChange={(e, data) => { onChange={(e, data) => {