mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-03-01 10:20:16 +01:00
🔥 移除旧版云端同步和备份功能入口 https://github.com/siyuan-note/siyuan/issues/5405
This commit is contained in:
parent
2863e32cff
commit
e936b9cf0b
5 changed files with 55 additions and 164 deletions
|
|
@ -27,6 +27,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/88250/gulu"
|
||||
"github.com/dustin/go-humanize"
|
||||
"github.com/siyuan-note/dejavu"
|
||||
"github.com/siyuan-note/dejavu/entity"
|
||||
"github.com/siyuan-note/encryption"
|
||||
|
|
@ -221,7 +222,7 @@ func DownloadCloudSnapshot(tag, id string) (err error) {
|
|||
if nil != err {
|
||||
return
|
||||
}
|
||||
msg := fmt.Sprintf(Conf.Language(153), downloadFileCount, downloadChunkCount, byteCountSI(downloadBytes))
|
||||
msg := fmt.Sprintf(Conf.Language(153), downloadFileCount, downloadChunkCount, humanize.Bytes(uint64(downloadBytes)))
|
||||
util.PushMsg(msg, 5000)
|
||||
util.PushStatusBar(msg)
|
||||
return
|
||||
|
|
@ -252,7 +253,7 @@ func UploadCloudSnapshot(tag, id string) (err error) {
|
|||
}
|
||||
return
|
||||
}
|
||||
msg := fmt.Sprintf(Conf.Language(152), uploadFileCount, uploadChunkCount, byteCountSI(uploadBytes))
|
||||
msg := fmt.Sprintf(Conf.Language(152), uploadFileCount, uploadChunkCount, humanize.Bytes(uint64(uploadBytes)))
|
||||
util.PushMsg(msg, 5000)
|
||||
util.PushStatusBar(msg)
|
||||
return
|
||||
|
|
@ -458,7 +459,7 @@ func syncRepo(boot, exit, byHand bool) {
|
|||
util.LogErrorf("sync data repo failed: %s", err)
|
||||
msg := fmt.Sprintf(Conf.Language(80), formatErrorMsg(err))
|
||||
if errors.Is(err, dejavu.ErrCloudStorageSizeExceeded) {
|
||||
msg = fmt.Sprintf(Conf.Language(43), byteCountSI(int64(Conf.User.UserSiYuanRepoSize)))
|
||||
msg = fmt.Sprintf(Conf.Language(43), humanize.Bytes(uint64(Conf.User.UserSiYuanRepoSize)))
|
||||
}
|
||||
Conf.Sync.Stat = msg
|
||||
util.PushStatusBar(msg)
|
||||
|
|
@ -474,7 +475,7 @@ func syncRepo(boot, exit, byHand bool) {
|
|||
}
|
||||
util.PushStatusBar(fmt.Sprintf(Conf.Language(149), elapsed.Seconds()))
|
||||
Conf.Sync.Synced = util.CurrentTimeMillis()
|
||||
msg := fmt.Sprintf(Conf.Language(150), trafficStat.UploadFileCount, trafficStat.DownloadFileCount, trafficStat.UploadChunkCount, trafficStat.DownloadChunkCount, byteCountSI(trafficStat.UploadBytes), byteCountSI(trafficStat.DownloadBytes))
|
||||
msg := fmt.Sprintf(Conf.Language(150), trafficStat.UploadFileCount, trafficStat.DownloadFileCount, trafficStat.UploadChunkCount, trafficStat.DownloadChunkCount, humanize.Bytes(uint64(trafficStat.UploadBytes)), humanize.Bytes(uint64(trafficStat.DownloadBytes)))
|
||||
Conf.Sync.Stat = msg
|
||||
|
||||
if 1 > len(mergeResult.Upserts) && 1 > len(mergeResult.Removes) { // 没有数据变更
|
||||
|
|
@ -740,6 +741,56 @@ func buildCloudInfo() (ret *dejavu.CloudInfo, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
type Backup struct {
|
||||
Size int64 `json:"size"`
|
||||
HSize string `json:"hSize"`
|
||||
Updated string `json:"updated"`
|
||||
SaveDir string `json:"saveDir"` // 本地备份数据存放目录路径
|
||||
}
|
||||
|
||||
type Sync struct {
|
||||
Size int64 `json:"size"`
|
||||
HSize string `json:"hSize"`
|
||||
Updated string `json:"updated"`
|
||||
CloudName string `json:"cloudName"` // 云端同步数据存放目录名
|
||||
SaveDir string `json:"saveDir"` // 本地同步数据存放目录路径
|
||||
}
|
||||
|
||||
func GetCloudSpace() (s *Sync, b *Backup, hSize, hAssetSize, hTotalSize string, err error) {
|
||||
sync, backup, assetSize, err := getCloudSpaceOSS()
|
||||
if nil != err {
|
||||
err = errors.New(Conf.Language(30) + " " + err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
var totalSize, syncSize, backupSize int64
|
||||
var syncUpdated, backupUpdated string
|
||||
if nil != sync {
|
||||
syncSize = int64(sync["size"].(float64))
|
||||
syncUpdated = sync["updated"].(string)
|
||||
}
|
||||
s = &Sync{
|
||||
Size: syncSize,
|
||||
HSize: humanize.Bytes(uint64(syncSize)),
|
||||
Updated: syncUpdated,
|
||||
}
|
||||
|
||||
if nil != backup {
|
||||
backupSize = int64(backup["size"].(float64))
|
||||
backupUpdated = backup["updated"].(string)
|
||||
}
|
||||
b = &Backup{
|
||||
Size: backupSize,
|
||||
HSize: humanize.Bytes(uint64(backupSize)),
|
||||
Updated: backupUpdated,
|
||||
}
|
||||
totalSize = syncSize + backupSize + assetSize
|
||||
hAssetSize = humanize.Bytes(uint64(assetSize))
|
||||
hSize = humanize.Bytes(uint64(totalSize))
|
||||
hTotalSize = humanize.Bytes(uint64(Conf.User.UserSiYuanRepoSize))
|
||||
return
|
||||
}
|
||||
|
||||
func getCloudSpaceOSS() (sync, backup map[string]interface{}, assetSize int64, err error) {
|
||||
result := map[string]interface{}{}
|
||||
resp, err := httpclient.NewCloudRequest().
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue