improve macos experience
This commit is contained in:
parent
f1986fa9d0
commit
d5cca4e542
@ -1,7 +1,9 @@
|
||||
package backend_golang
|
||||
|
||||
import (
|
||||
"archive/zip"
|
||||
"bufio"
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"io"
|
||||
@ -10,6 +12,7 @@ import (
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
@ -160,6 +163,7 @@ func (a *App) UpdateApp(url string) (broken bool, err error) {
|
||||
ticker := time.NewTicker(250 * time.Millisecond)
|
||||
defer ticker.Stop()
|
||||
|
||||
// update progress
|
||||
go func() {
|
||||
for {
|
||||
<-ticker.C
|
||||
@ -179,13 +183,35 @@ func (a *App) UpdateApp(url string) (broken bool, err error) {
|
||||
}
|
||||
}
|
||||
}()
|
||||
err = selfupdate.Apply(pr, selfupdate.Options{})
|
||||
|
||||
var updateFile io.Reader = pr
|
||||
// extract macos binary from zip
|
||||
if strings.HasSuffix(url, ".zip") && runtime.GOOS == "darwin" {
|
||||
zipBytes, err := io.ReadAll(pr)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
archive, err := zip.NewReader(bytes.NewReader(zipBytes), int64(len(zipBytes)))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
file, err := archive.Open("Contents/MacOS/RWKV-Runner")
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
defer file.Close()
|
||||
updateFile = file
|
||||
}
|
||||
|
||||
// apply update
|
||||
err = selfupdate.Apply(updateFile, selfupdate.Options{})
|
||||
if err != nil {
|
||||
if rerr := selfupdate.RollbackError(err); rerr != nil {
|
||||
return true, rerr
|
||||
}
|
||||
return false, err
|
||||
}
|
||||
// restart app
|
||||
if runtime.GOOS == "windows" {
|
||||
name, err := os.Executable()
|
||||
if err != nil {
|
||||
|
@ -272,7 +272,6 @@ const Settings: FC = observer(() => {
|
||||
<AccordionHeader ref={advancedHeaderRef} size="large">{t('Advanced')}</AccordionHeader>
|
||||
<AccordionPanel>
|
||||
<div className="flex flex-col gap-2 overflow-hidden">
|
||||
{commonStore.platform !== 'darwin' &&
|
||||
<Labeled label={t('Custom Models Path')}
|
||||
content={
|
||||
<Input className="grow" placeholder="./models"
|
||||
@ -283,7 +282,6 @@ const Settings: FC = observer(() => {
|
||||
});
|
||||
}} />
|
||||
} />
|
||||
}
|
||||
<Labeled label={t('Custom Python Path')} // if set, will not use precompiled cuda kernel
|
||||
content={
|
||||
<Input className="grow" placeholder="./py310/python"
|
||||
|
@ -419,6 +419,7 @@ const LoraFinetune: FC = observer(() => {
|
||||
outputPrefix,
|
||||
dataParams.vocabPath).then(async () => {
|
||||
if (!await FileExists(outputPrefix + '_text_document.idx')) {
|
||||
if (commonStore.platform === 'windows' || commonStore.platform === 'linux')
|
||||
toast(t('Failed to convert data') + ' - ' + await GetPyError(), { type: 'error' });
|
||||
} else {
|
||||
toast(t('Convert Data successfully'), { type: 'success' });
|
||||
|
@ -352,7 +352,7 @@ export async function checkUpdate(notifyEvenLatest: boolean = false) {
|
||||
if (r.ok) {
|
||||
r.json().then((data) => {
|
||||
if (data.assets && data.assets.length > 0) {
|
||||
const asset = data.assets.find((a: any) => a.name.toLowerCase().includes(commonStore.platform.toLowerCase()));
|
||||
const asset = data.assets.find((a: any) => a.name.toLowerCase().includes(commonStore.platform.toLowerCase().replace('darwin', 'macos')));
|
||||
if (asset) {
|
||||
const updateUrl = !commonStore.settings.giteeUpdatesSource ?
|
||||
`https://github.com/josStorer/RWKV-Runner/releases/download/${versionTag}/${asset.name}` :
|
||||
|
Loading…
Reference in New Issue
Block a user