improve upgrade process

This commit is contained in:
josc146 2023-05-24 23:05:19 +08:00
parent 9f080b63e0
commit 5192e31bac
3 changed files with 20 additions and 5 deletions

View File

@ -144,8 +144,12 @@ export const RunButton: FC<{ onClickRun?: MouseEventHandler, iconMode?: boolean
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(() => {
FileExists('./py310/Lib/site-packages/rwkv/wkv_cuda.pyd').then((exist) => {
if (!exist) {
customCudaFile = '';
toast(t('Failed to copy custom cuda file'), { type: 'error' });
}
});
});
} else
toast(t('Supported custom cuda file not found'), { type: 'warning' });

View File

@ -3,8 +3,8 @@ import { FileExists, ReadJson } from '../wailsjs/go/backend_golang/App';
import {
Cache,
checkUpdate,
deleteDynamicProgramFiles,
downloadProgramFiles,
forceDownloadProgramFiles,
LocalConfig,
refreshModels,
saveCache
@ -17,8 +17,9 @@ export async function startup() {
FileExists('cache.json').then((exists) => {
if (exists)
downloadProgramFiles();
else
forceDownloadProgramFiles();
else {
deleteDynamicProgramFiles().then(downloadProgramFiles);
}
});
EventsOn('downloadList', (data) => {
if (data)

View File

@ -188,6 +188,16 @@ export function forceDownloadProgramFiles() {
});
}
export async function deleteDynamicProgramFiles() {
let promises: Promise<void>[] = [];
manifest.programFiles.forEach(({ path }) => {
if ((path.endsWith('.py') && !path.includes('get-pip.py')) || path.includes('requirements') || path.endsWith('.pyd'))
promises.push(DeleteFile(path));
});
return await Promise.allSettled(promises).catch(() => {
});
}
export function bytesToGb(size: number) {
return (size / 1024 / 1024 / 1024).toFixed(2);
}