mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-27 17:34:06 +01:00
This commit is contained in:
parent
29117c764d
commit
b371692509
4 changed files with 56 additions and 23 deletions
|
|
@ -28,25 +28,28 @@ import (
|
|||
"github.com/siyuan-note/dejavu"
|
||||
"github.com/siyuan-note/dejavu/entity"
|
||||
"github.com/siyuan-note/encryption"
|
||||
"github.com/siyuan-note/eventbus"
|
||||
"github.com/siyuan-note/filelock"
|
||||
"github.com/siyuan-note/siyuan/kernel/sql"
|
||||
"github.com/siyuan-note/siyuan/kernel/util"
|
||||
)
|
||||
|
||||
func UploadSnapshot(id string) (err error) {
|
||||
if 1 > len(Conf.Repo.Key) {
|
||||
err = errors.New(Conf.Language(26))
|
||||
return
|
||||
}
|
||||
func init() {
|
||||
eventbus.Subscribe(dejavu.EvtSyncBeforeDownloadCloudIndexes, func(latestSync string) {
|
||||
util.SetBootDetails("Downloading repo indexes...")
|
||||
})
|
||||
|
||||
repo, err := dejavu.NewRepo(util.DataDir, util.RepoDir, Conf.Repo.Key)
|
||||
if nil != err {
|
||||
util.LogErrorf("init repo failed: %s", err)
|
||||
return
|
||||
}
|
||||
eventbus.Subscribe(dejavu.EvtSyncBeforeDownloadCloudFile, func(id string) {
|
||||
util.SetBootDetails("Downloading repo object [" + id + "]")
|
||||
})
|
||||
|
||||
_ = repo
|
||||
return
|
||||
eventbus.Subscribe(dejavu.EvtSyncBeforeDownloadCloudChunk, func(id string) {
|
||||
util.SetBootDetails("Downloading repo object [" + id + "]")
|
||||
})
|
||||
|
||||
eventbus.Subscribe(dejavu.EvtSyncBeforeUploadObject, func(id string) {
|
||||
util.SetBootDetails("Uploading repo object [" + id + "]")
|
||||
})
|
||||
}
|
||||
|
||||
func GetRepoIndexLogs(page int) (logs []*dejavu.Log, pageCount, totalCount int, err error) {
|
||||
|
|
@ -288,3 +291,21 @@ func indexRepoBeforeCloudSync() {
|
|||
util.LogWarnf("index repo before cloud sync elapsed [%dms]", elapsed.Milliseconds())
|
||||
}
|
||||
}
|
||||
|
||||
func syncRepo() (err error) {
|
||||
if 1 > len(Conf.Repo.Key) {
|
||||
return
|
||||
}
|
||||
|
||||
repo, err := dejavu.NewRepo(util.DataDir, util.RepoDir, Conf.Repo.Key)
|
||||
if nil != err {
|
||||
util.LogErrorf("init repo failed: %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
start := time.Now()
|
||||
err = repo.Sync(Conf.Sync.CloudName, Conf.User.UserId, Conf.User.UserToken, Conf.System.NetworkProxy.String(), util.AliyunServer)
|
||||
elapsed := time.Since(start)
|
||||
util.LogInfof("sync repo elapsed [%.2fs]", elapsed.Seconds())
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -154,6 +154,11 @@ func SyncData(boot, exit, byHand bool) {
|
|||
// 创建数据快照 https://github.com/siyuan-note/siyuan/issues/5161
|
||||
indexRepoBeforeCloudSync()
|
||||
|
||||
// 同步数据仓库
|
||||
if syncRepoErr := syncRepo(); nil != syncRepoErr {
|
||||
util.LogErrorf("sync repo failed: %s", syncRepoErr)
|
||||
}
|
||||
|
||||
// 获取工作空间数据配置(数据版本)
|
||||
dataConf, err := getWorkspaceDataConf()
|
||||
if nil != err {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue