fix CopyFile api

This commit is contained in:
josc146 2023-05-23 14:36:24 +08:00
parent 89c8545528
commit 5e4f6159be
2 changed files with 7 additions and 3 deletions

View File

@ -106,7 +106,7 @@ func (a *App) CopyFile(src string, dst string) error {
} }
defer destFile.Close() defer destFile.Close()
_, err = io.Copy(sourceFile, destFile) _, err = io.Copy(destFile, sourceFile)
if err != nil { if err != nil {
return err return err
} }

View File

@ -138,12 +138,16 @@ export const RunButton: FC<{ onClickRun?: MouseEventHandler, iconMode?: boolean
let customCudaFile = ''; let customCudaFile = '';
if (modelConfig.modelParameters.useCustomCuda) { if (modelConfig.modelParameters.useCustomCuda) {
customCudaFile = getSupportedCustomCudaFile(); customCudaFile = getSupportedCustomCudaFile();
if (customCudaFile) if (customCudaFile) {
FileExists('./py310/Lib/site-packages/rwkv/model.py').then((exist) => {
// defensive measure. As Python has already been launched, will only take effect the next time it runs.
if (!exist) CopyFile('./backend-python/wkv_cuda_utils/wkv_cuda_model.py', './py310/Lib/site-packages/rwkv/model.py');
});
await CopyFile(customCudaFile, './py310/Lib/site-packages/rwkv/wkv_cuda.pyd').catch(() => { await CopyFile(customCudaFile, './py310/Lib/site-packages/rwkv/wkv_cuda.pyd').catch(() => {
customCudaFile = ''; customCudaFile = '';
toast(t('Failed to copy custom cuda file'), { type: 'error' }); toast(t('Failed to copy custom cuda file'), { type: 'error' });
}); });
else } else
toast(t('Supported custom cuda file not found'), { type: 'warning' }); toast(t('Supported custom cuda file not found'), { type: 'warning' });
} }