🎨 桌面端自动下载更新安装包 https://github.com/siyuan-note/siyuan/issues/5837
This commit is contained in:
parent
8399f852a4
commit
710959a8c1
7 changed files with 40 additions and 15 deletions
|
@ -836,7 +836,7 @@
|
|||
"58": "After the index is rebuilt, the interface will be automatically refreshed later...",
|
||||
"59": "Failed to set sync ignore list",
|
||||
"60": "Failed to get the update package: %s",
|
||||
"61": "TODO",
|
||||
"61": "The new version installation package is ready, do you want to exit now and start installing the new version?",
|
||||
"62": "TODO",
|
||||
"63": "Recovering, please wait...",
|
||||
"64": "There are [%d] files in total, it will take some time to index, please wait...",
|
||||
|
|
|
@ -836,7 +836,7 @@
|
|||
"58": "Después de reconstruir el índice, la interfaz se actualizará automáticamente más tarde...",
|
||||
"59": " Falló la configuración de sincronización de la lista de ignorados",
|
||||
"60": "Fallo al obtener el paquete de actualización: %s",
|
||||
"61": "TODO",
|
||||
"61": "El paquete de instalación de la nueva versión está listo, ¿quieres salir ahora y comenzar a instalar la nueva versión?",
|
||||
"62": "TODO",
|
||||
"63": "Recuperando, por favor espere...",
|
||||
"64": "Hay [%d] archivos en total, tardará un tiempo en indexarse, por favor espere...",
|
||||
|
|
|
@ -836,7 +836,7 @@
|
|||
"58": "Une fois l'index reconstruit, l'interface sera automatiquement rafraîchie ultérieurement...",
|
||||
"59": "Échec de la définition de la liste des ignores de synchronisation",
|
||||
"60": "Échec de la récupération du paquet de mise à jour : %s",
|
||||
"61": "TODO",
|
||||
"61": "Le package d'installation de la nouvelle version est prêt, voulez-vous quitter maintenant et commencer l'installation de la nouvelle version ?",
|
||||
"62": "TODO",
|
||||
"63": "Récupération, veuillez patienter...",
|
||||
"64": "Il y a [%d] fichiers au total, l'indexation prendra un certain temps, veuillez patienter...",
|
||||
|
|
|
@ -836,7 +836,7 @@
|
|||
"58": "重建索引完畢,稍後將自動重新整理介面...",
|
||||
"59": "設置同步忽略列表失敗",
|
||||
"60": "獲取更新包失敗:%s",
|
||||
"61": "TODO",
|
||||
"61": "新版本安裝包已經準備就緒,是否現在退出並開始安裝新版本?",
|
||||
"62": "TODO",
|
||||
"63": "正在恢復,請稍等...",
|
||||
"64": "共有檔 [%d] 個,需要一些時間進行索引,請稍等...",
|
||||
|
|
|
@ -837,7 +837,7 @@
|
|||
"58": "重建索引完毕,稍后将自动刷新界面...",
|
||||
"59": "设置同步忽略列表失败",
|
||||
"60": "获取更新包失败:%s",
|
||||
"61": "TODO",
|
||||
"61": "新版本安装包已经准备就绪,是否现在退出并开始安装新版本?",
|
||||
"62": "TODO",
|
||||
"63": "正在恢复,请稍等...",
|
||||
"64": "共有文件 [%d] 个,需要一些时间进行索引,请稍等...",
|
||||
|
|
|
@ -238,6 +238,9 @@ func AutoRefreshCheck() {
|
|||
go func() {
|
||||
defer logging.Recover()
|
||||
checkDownloadInstallPkg()
|
||||
if isExistUpdateInstallPkg() {
|
||||
util.PushMsg(Conf.Language(61), 0)
|
||||
}
|
||||
}()
|
||||
|
||||
<-refreshCheckTicker.C
|
||||
|
|
|
@ -22,6 +22,7 @@ import (
|
|||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"sync"
|
||||
|
@ -33,6 +34,18 @@ import (
|
|||
"github.com/siyuan-note/siyuan/kernel/util"
|
||||
)
|
||||
|
||||
func isExistUpdateInstallPkg() bool {
|
||||
downloadPkgURL, checksum, err := getUpdatePkg()
|
||||
if nil != err {
|
||||
return false
|
||||
}
|
||||
|
||||
pkg := path.Base(downloadPkgURL)
|
||||
savePath := filepath.Join(util.TempDir, "install", pkg)
|
||||
localChecksum, _ := sha256Hash(savePath)
|
||||
return checksum == localChecksum
|
||||
}
|
||||
|
||||
var checkDownloadInstallPkgLock = sync.Mutex{}
|
||||
|
||||
func checkDownloadInstallPkg() {
|
||||
|
@ -49,6 +62,15 @@ func checkDownloadInstallPkg() {
|
|||
checkDownloadInstallPkgLock.Lock()
|
||||
defer checkDownloadInstallPkgLock.Unlock()
|
||||
|
||||
downloadPkgURL, checksum, err := getUpdatePkg()
|
||||
if nil != err {
|
||||
return
|
||||
}
|
||||
|
||||
downloadInstallPkg(downloadPkgURL, checksum)
|
||||
}
|
||||
|
||||
func getUpdatePkg() (downloadPkgURL, checksum string, err error) {
|
||||
result, err := util.GetRhyResult(false)
|
||||
if nil != err {
|
||||
return
|
||||
|
@ -56,9 +78,10 @@ func checkDownloadInstallPkg() {
|
|||
|
||||
installPkgSite := result["installPkg"].(string)
|
||||
ver := result["ver"].(string)
|
||||
if ver == util.Ver {
|
||||
return
|
||||
}
|
||||
// TODO: v2.1.14 桌面端自动下载更新安装包 https://github.com/siyuan-note/siyuan/issues/5837
|
||||
//if ver == util.Ver {
|
||||
// return
|
||||
//}
|
||||
|
||||
var suffix string
|
||||
if gulu.OS.IsWindows() {
|
||||
|
@ -77,16 +100,15 @@ func checkDownloadInstallPkg() {
|
|||
suffix = "linux.AppImage"
|
||||
}
|
||||
pkg := "siyuan-" + ver + "-" + suffix
|
||||
installPkg := "siyuan/" + pkg
|
||||
downloadPkgURL := installPkgSite + installPkg
|
||||
localPkgPath := filepath.Join(util.TempDir, "install", pkg)
|
||||
downloadPkgURL = installPkgSite + "siyuan/" + pkg
|
||||
checksums := result["checksums"].(map[string]interface{})
|
||||
checksum := checksums[pkg].(string)
|
||||
|
||||
downloadInstallPkg(downloadPkgURL, checksum, localPkgPath)
|
||||
checksum = checksums[pkg].(string)
|
||||
return
|
||||
}
|
||||
|
||||
func downloadInstallPkg(pkgURL, checksum, savePath string) {
|
||||
func downloadInstallPkg(pkgURL, checksum string) {
|
||||
pkg := path.Base(pkgURL)
|
||||
savePath := filepath.Join(util.TempDir, "install", pkg)
|
||||
if gulu.File.IsExist(savePath) {
|
||||
localChecksum, _ := sha256Hash(savePath)
|
||||
if localChecksum == checksum {
|
||||
|
|
Loading…
Add table
Reference in a new issue