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