mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-06 16:58:49 +01:00
This commit is contained in:
parent
177b42c1ef
commit
e4b712547f
9 changed files with 22 additions and 14 deletions
|
|
@ -59,9 +59,7 @@ func RemoveCloudBackup() (err error) {
|
|||
}
|
||||
|
||||
func getCloudAvailableBackupSize() (size int64, err error) {
|
||||
var sync map[string]interface{}
|
||||
var assetSize int64
|
||||
sync, _, assetSize, err = getCloudSpaceOSS()
|
||||
sync, _, assetSize, repoSize, err := getCloudSpaceOSS()
|
||||
if nil != err {
|
||||
return
|
||||
}
|
||||
|
|
@ -70,16 +68,15 @@ func getCloudAvailableBackupSize() (size int64, err error) {
|
|||
if nil != sync {
|
||||
syncSize = int64(sync["size"].(float64))
|
||||
}
|
||||
size = int64(Conf.User.UserSiYuanRepoSize) - syncSize - assetSize
|
||||
size = int64(Conf.User.UserSiYuanRepoSize) - syncSize - assetSize - repoSize
|
||||
return
|
||||
}
|
||||
|
||||
func GetCloudSpace() (s *Sync, b *Backup, hSize, hAssetSize, hTotalSize string, err error) {
|
||||
var sync, backup map[string]interface{}
|
||||
var assetSize int64
|
||||
sync, backup, assetSize, err = getCloudSpaceOSS()
|
||||
func GetCloudSpace() (s *Sync, b *Backup, hSize, hAssetSize, hRepoSize, hTotalSize string, err error) {
|
||||
sync, backup, assetSize, repoSize, err := getCloudSpaceOSS()
|
||||
if nil != err {
|
||||
return nil, nil, "", "", "", errors.New(Conf.Language(30) + " " + err.Error())
|
||||
err = errors.New(Conf.Language(30) + " " + err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
var totalSize, syncSize, backupSize int64
|
||||
|
|
@ -103,8 +100,9 @@ func GetCloudSpace() (s *Sync, b *Backup, hSize, hAssetSize, hTotalSize string,
|
|||
HSize: humanize.Bytes(uint64(backupSize)),
|
||||
Updated: backupUpdated,
|
||||
}
|
||||
totalSize = syncSize + backupSize + assetSize
|
||||
totalSize = syncSize + backupSize + assetSize + repoSize
|
||||
hAssetSize = humanize.Bytes(uint64(assetSize))
|
||||
hRepoSize = humanize.Bytes(uint64(repoSize))
|
||||
hSize = humanize.Bytes(uint64(totalSize))
|
||||
hTotalSize = byteCountSI(int64(Conf.User.UserSiYuanRepoSize))
|
||||
return
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ import (
|
|||
"github.com/siyuan-note/siyuan/kernel/util"
|
||||
)
|
||||
|
||||
func getCloudSpaceOSS() (sync, backup map[string]interface{}, assetSize int64, err error) {
|
||||
func getCloudSpaceOSS() (sync, backup map[string]interface{}, assetSize, repoSize int64, err error) {
|
||||
result := map[string]interface{}{}
|
||||
request := httpclient.NewCloudRequest(Conf.System.NetworkProxy.String())
|
||||
resp, err := request.
|
||||
|
|
@ -47,7 +47,8 @@ func getCloudSpaceOSS() (sync, backup map[string]interface{}, assetSize int64, e
|
|||
Post(util.AliyunServer + "/apis/siyuan/data/getSiYuanWorkspace?uid=" + Conf.User.UserId)
|
||||
if nil != err {
|
||||
util.LogErrorf("get cloud space failed: %s", err)
|
||||
return nil, nil, 0, ErrFailedToConnectCloudServer
|
||||
err = ErrFailedToConnectCloudServer
|
||||
return
|
||||
}
|
||||
|
||||
if 401 == resp.StatusCode {
|
||||
|
|
@ -58,13 +59,15 @@ func getCloudSpaceOSS() (sync, backup map[string]interface{}, assetSize int64, e
|
|||
code := result["code"].(float64)
|
||||
if 0 != code {
|
||||
util.LogErrorf("get cloud space failed: %s", result["msg"])
|
||||
return nil, nil, 0, errors.New(result["msg"].(string))
|
||||
err = errors.New(result["msg"].(string))
|
||||
return
|
||||
}
|
||||
|
||||
data := result["data"].(map[string]interface{})
|
||||
sync = data["sync"].(map[string]interface{})
|
||||
backup = data["backup"].(map[string]interface{})
|
||||
assetSize = int64(data["assetSize"].(float64))
|
||||
repoSize = int64(data["repoSize"].(float64))
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue