Skip to content

Commit

Permalink
update version
Browse files Browse the repository at this point in the history
  • Loading branch information
appdev committed Nov 14, 2023
1 parent 9482d18 commit 97fc6af
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 136 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ private void initUIElements() {
bootProgressBar = findViewById(R.id.progressBar);
bootDetailsText = findViewById(R.id.bootDetails);
webView = findViewById(R.id.webView);
WebView.setWebContentsDebuggingEnabled(BuildConfig.DEBUG);
webView.setBackgroundColor(Color.parseColor("#1e1e1e"));
webView.setWebChromeClient(new WebChromeClient() {
@Override
Expand Down
128 changes: 50 additions & 78 deletions app/src/config/repos.ts
Original file line number Diff line number Diff line change
@@ -1,42 +1,14 @@
import {needLogin, needSubscribe} from "../util/needSubscribe";
import {needLogin} from "../util/needSubscribe";
import {fetchPost} from "../util/fetch";
import {showMessage} from "../dialog/message";
import {bindSyncCloudListEvent, getSyncCloudList} from "../sync/syncGuide";
import {processSync} from "../dialog/processSystem";
import {getCloudURL} from "./util/about";
import {openByMobile} from "../protyle/util/compatibility";

const renderProvider = (provider: number) => {
if (provider === 0) {
if (needSubscribe("")) {
return `<div class="b3-label b3-label--inner">${window.siyuan.config.system.container === "ios" ? window.siyuan.languages._kernel[122] : window.siyuan.languages._kernel[29].replace("${url}", getCloudURL("subscribe/siyuan"))}</div>
<div class="b3-label b3-label--noborder">
${window.siyuan.languages.cloudIntro1}
<div class="b3-label__text">
<ul class="fn__list">
<li>${window.siyuan.languages.cloudIntro2}</li>
<li>${window.siyuan.languages.cloudIntro3}</li>
<li>${window.siyuan.languages.cloudIntro4}</li>
<li>${window.siyuan.languages.cloudIntro5}</li>
<li>${window.siyuan.languages.cloudIntro6}</li>
<li>${window.siyuan.languages.cloudIntro7}</li>
<li>${window.siyuan.languages.cloudIntro8}</li>
</ul>
</div>
</div>
<div class="b3-label b3-label--noborder">
${window.siyuan.languages.cloudIntro9}
<div class="b3-label__text">
<ul style="padding-left: 2em">
<li>${window.siyuan.languages.cloudIntro10}</li>
<li>${window.siyuan.languages.cloudIntro11}</li>
</ul>
</div>
</div>`;
}
return `<div class="b3-label b3-label--inner">
${window.siyuan.languages.syncOfficialProviderIntro}
</div>`;
window.siyuan.config.sync.provider = 2;
provider = 2;
}
if (needLogin("")) {
return `<div class="b3-label b3-label--inner">${window.siyuan.languages.needLogin}</div>`;
Expand Down Expand Up @@ -186,51 +158,51 @@ const bindProviderEvent = () => {

const reposDataElement = repos.element.querySelector("#reposData");
const loadingElement = repos.element.querySelector("#reposLoading");
if (window.siyuan.config.sync.provider === 0) {
if (needSubscribe("")) {
loadingElement.classList.add("fn__none");
let nextElement = reposDataElement;
while (nextElement) {
nextElement.classList.add("fn__none");
nextElement = nextElement.nextElementSibling;
}
return;
}
fetchPost("/api/cloud/getCloudSpace", {}, (response) => {
loadingElement.classList.add("fn__none");
if (response.code === 1) {
reposDataElement.innerHTML = response.msg;
return;
} else {
reposDataElement.innerHTML = `<div class="fn__flex">
<div class="fn__flex-1">
${window.siyuan.languages.cloudStorage}
<div class="fn__hr"></div>
<ul class="b3-list" style="margin-left: 12px">
<li class="b3-list-item" style="cursor: auto;">${window.siyuan.languages.sync}<span class="b3-list-item__meta">${response.data.sync ? response.data.sync.hSize : "0B"}</span></li>
<li class="b3-list-item" style="cursor: auto;">${window.siyuan.languages.backup}<span class="b3-list-item__meta">${response.data.backup ? response.data.backup.hSize : "0B"}</span></li>
<li class="b3-list-item" style="cursor: auto;"><a href="${getCloudURL("settings/file?type=3")}" target="_blank">${window.siyuan.languages.cdn}</a><span class="b3-list-item__meta">${response.data.hAssetSize}</span></li>
<li class="b3-list-item" style="cursor: auto;">${window.siyuan.languages.total}<span class="b3-list-item__meta">${response.data.hSize}</span></li>
<li class="b3-list-item" style="cursor: auto;">${window.siyuan.languages.sizeLimit}<span class="b3-list-item__meta">${response.data.hTotalSize}</span></li>
<li class="b3-list-item" style="cursor: auto;"><a href="${getCloudURL("settings/point")}" target="_blank">${window.siyuan.languages.pointExchangeSize}</a><span class="b3-list-item__meta">${response.data.hExchangeSize}</span></li>
</ul>
</div>
<div class="fn__flex-1">
${window.siyuan.languages.trafficStat}
<div class="fn__hr"></div>
<ul class="b3-list" style="margin-left: 12px">
<li class="b3-list-item" style="cursor: auto;">${window.siyuan.languages.upload}<span class="fn__space"></span><span class="ft__on-surface">${response.data.hTrafficUploadSize}</span></li>
<li class="b3-list-item" style="cursor: auto;">${window.siyuan.languages.download}<span class="fn__space"></span><span class="ft__on-surface">${response.data.hTrafficDownloadSize}</span></li>
<li class="b3-list-item" style="cursor: auto;">API GET<span class="fn__space"></span><span class="ft__on-surface">${response.data.hTrafficAPIGet}</span></li>
<li class="b3-list-item" style="cursor: auto;">API PUT<span class="fn__space"></span><span class="ft__on-surface">${response.data.hTrafficAPIPut}</span></li>
</ul>
</div>
</div>`;
}
});
reposDataElement.classList.remove("fn__none");
return;
}
// if (window.siyuan.config.sync.provider === 0) {
// if (needSubscribe("")) {
// loadingElement.classList.add("fn__none");
// let nextElement = reposDataElement;
// while (nextElement) {
// nextElement.classList.add("fn__none");
// nextElement = nextElement.nextElementSibling;
// }
// return;
// }
// fetchPost("/api/cloud/getCloudSpace", {}, (response) => {
// loadingElement.classList.add("fn__none");
// if (response.code === 1) {
// reposDataElement.innerHTML = response.msg;
// return;
// } else {
// reposDataElement.innerHTML = `<div class="fn__flex">
// <div class="fn__flex-1">
// ${window.siyuan.languages.cloudStorage}
// <div class="fn__hr"></div>
// <ul class="b3-list" style="margin-left: 12px">
// <li class="b3-list-item" style="cursor: auto;">${window.siyuan.languages.sync}<span class="b3-list-item__meta">${response.data.sync ? response.data.sync.hSize : "0B"}</span></li>
// <li class="b3-list-item" style="cursor: auto;">${window.siyuan.languages.backup}<span class="b3-list-item__meta">${response.data.backup ? response.data.backup.hSize : "0B"}</span></li>
// <li class="b3-list-item" style="cursor: auto;"><a href="${getCloudURL("settings/file?type=3")}" target="_blank">${window.siyuan.languages.cdn}</a><span class="b3-list-item__meta">${response.data.hAssetSize}</span></li>
// <li class="b3-list-item" style="cursor: auto;">${window.siyuan.languages.total}<span class="b3-list-item__meta">${response.data.hSize}</span></li>
// <li class="b3-list-item" style="cursor: auto;">${window.siyuan.languages.sizeLimit}<span class="b3-list-item__meta">${response.data.hTotalSize}</span></li>
// <li class="b3-list-item" style="cursor: auto;"><a href="${getCloudURL("settings/point")}" target="_blank">${window.siyuan.languages.pointExchangeSize}</a><span class="b3-list-item__meta">${response.data.hExchangeSize}</span></li>
// </ul>
// </div>
// <div class="fn__flex-1">
// ${window.siyuan.languages.trafficStat}
// <div class="fn__hr"></div>
// <ul class="b3-list" style="margin-left: 12px">
// <li class="b3-list-item" style="cursor: auto;">${window.siyuan.languages.upload}<span class="fn__space"></span><span class="ft__on-surface">${response.data.hTrafficUploadSize}</span></li>
// <li class="b3-list-item" style="cursor: auto;">${window.siyuan.languages.download}<span class="fn__space"></span><span class="ft__on-surface">${response.data.hTrafficDownloadSize}</span></li>
// <li class="b3-list-item" style="cursor: auto;">API GET<span class="fn__space"></span><span class="ft__on-surface">${response.data.hTrafficAPIGet}</span></li>
// <li class="b3-list-item" style="cursor: auto;">API PUT<span class="fn__space"></span><span class="ft__on-surface">${response.data.hTrafficAPIPut}</span></li>
// </ul>
// </div>
// </div>`;
// }
// });
// reposDataElement.classList.remove("fn__none");
// return;
// }

loadingElement.classList.add("fn__none");
let nextElement = reposDataElement.nextElementSibling;
Expand Down Expand Up @@ -426,8 +398,8 @@ export const repos = {
fetchPost("/api/sync/setSyncProvider", {provider: parseInt(syncProviderElement.value, 10)}, (response) => {
if (response.code === 1) {
showMessage(response.msg);
syncProviderElement.value = "0";
window.siyuan.config.sync.provider = 0;
syncProviderElement.value = "2";
window.siyuan.config.sync.provider = 2;
} else {
window.siyuan.config.sync.provider = parseInt(syncProviderElement.value, 10);
}
Expand Down
59 changes: 1 addition & 58 deletions kernel/model/updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
"strconv"
"strings"
"sync"
"time"

"github.com/88250/gulu"
"github.com/siyuan-note/logging"
Expand Down Expand Up @@ -75,7 +74,6 @@ func getNewVerInstallPkgPath() string {
var checkDownloadInstallPkgLock = sync.Mutex{}

func checkDownloadInstallPkg() {
return
defer logging.Recover()

if skipNewVerInstallPkg() {
Expand Down Expand Up @@ -146,45 +144,6 @@ func getUpdatePkg() (downloadPkgURLs []string, checksum string, err error) {
}

func downloadInstallPkg(pkgURL, checksum string) (err error) {
if "" == pkgURL || "" == checksum {
return
}

pkg := path.Base(pkgURL)
savePath := filepath.Join(util.TempDir, "install", pkg)
if gulu.File.IsExist(savePath) {
localChecksum, _ := sha256Hash(savePath)
if localChecksum == checksum {
return
}
}

err = os.MkdirAll(filepath.Join(util.TempDir, "install"), 0755)
if nil != err {
logging.LogErrorf("create temp install dir failed: %s", err)
return
}

logging.LogInfof("downloading install package [%s]", pkgURL)
client := req.C().SetTLSHandshakeTimeout(7 * time.Second).SetTimeout(10 * time.Minute).DisableInsecureSkipVerify()
callback := func(info req.DownloadInfo) {
progress := fmt.Sprintf("%.2f%%", float64(info.DownloadedSize)/float64(info.Response.ContentLength)*100.0)
// logging.LogDebugf("downloading install package [%s %s]", pkgURL, progress)
util.PushStatusBar(fmt.Sprintf(Conf.Language(133), progress))
}
_, err = client.R().SetOutputFile(savePath).SetDownloadCallbackWithInterval(callback, 1*time.Second).Get(pkgURL)
if nil != err {
logging.LogErrorf("download install package [%s] failed: %s", pkgURL, err)
return
}

localChecksum, _ := sha256Hash(savePath)
if checksum != localChecksum {
logging.LogErrorf("verify checksum failed, download install package [%s] checksum [%s] not equal to downloaded [%s] checksum [%s]", pkgURL, checksum, savePath, localChecksum)
return
}
logging.LogInfof("downloaded install package [%s] to [%s]", pkgURL, savePath)
util.PushStatusBar(Conf.Language(62))
return
}

Expand Down Expand Up @@ -282,23 +241,7 @@ func isVersionUpToDate(releaseVer string) bool {
}

func skipNewVerInstallPkg() bool {
if !gulu.OS.IsWindows() && !gulu.OS.IsDarwin() {
return true
}
if util.ISMicrosoftStore || util.ContainerStd != util.Container {
return true
}
if !Conf.System.DownloadInstallPkg {
return true
}
if gulu.OS.IsWindows() {
plat := strings.ToLower(Conf.System.OSPlatform)
// Windows 7, 8 and Server 2012 are no longer supported https://github.com/siyuan-note/siyuan/issues/7347
if strings.Contains(plat, " 7 ") || strings.Contains(plat, " 8 ") || strings.Contains(plat, "2012") {
return true
}
}
return false
return true
}

func ver2num(a string) int {
Expand Down

0 comments on commit 97fc6af

Please sign in to comment.