mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-04 07:48:49 +01:00
🎨 Sync repo
This commit is contained in:
parent
8f4aa20f2d
commit
8a587c23e2
8 changed files with 25 additions and 21 deletions
|
|
@ -54,7 +54,7 @@ func generateDocHistory() {
|
|||
box.generateDocHistory0()
|
||||
}
|
||||
|
||||
historyDir := filepath.Join(util.WorkspaceDir, "history")
|
||||
historyDir := util.HistoryDir
|
||||
clearOutdatedHistoryDir(historyDir)
|
||||
|
||||
// 以下部分是老版本的清理逻辑,暂时保留
|
||||
|
|
@ -79,7 +79,7 @@ func ChangeHistoryTick(minutes int) {
|
|||
}
|
||||
|
||||
func ClearWorkspaceHistory() (err error) {
|
||||
historyDir := filepath.Join(util.WorkspaceDir, "history")
|
||||
historyDir := util.HistoryDir
|
||||
if gulu.File.IsDir(historyDir) {
|
||||
if err = os.RemoveAll(historyDir); nil != err {
|
||||
util.LogErrorf("remove workspace history dir [%s] failed: %s", historyDir, err)
|
||||
|
|
@ -257,7 +257,7 @@ const maxHistory = 32
|
|||
func GetDocHistory(boxID string) (ret []*History, err error) {
|
||||
ret = []*History{}
|
||||
|
||||
historyDir := filepath.Join(util.WorkspaceDir, "history")
|
||||
historyDir := util.HistoryDir
|
||||
if !gulu.File.IsDir(historyDir) {
|
||||
return
|
||||
}
|
||||
|
|
@ -342,7 +342,7 @@ func GetDocHistory(boxID string) (ret []*History, err error) {
|
|||
func GetNotebookHistory() (ret []*History, err error) {
|
||||
ret = []*History{}
|
||||
|
||||
historyDir := filepath.Join(util.WorkspaceDir, "history")
|
||||
historyDir := util.HistoryDir
|
||||
if !gulu.File.IsDir(historyDir) {
|
||||
return
|
||||
}
|
||||
|
|
@ -402,7 +402,7 @@ func GetNotebookHistory() (ret []*History, err error) {
|
|||
func GetAssetsHistory() (ret []*History, err error) {
|
||||
ret = []*History{}
|
||||
|
||||
historyDir := filepath.Join(util.WorkspaceDir, "history")
|
||||
historyDir := util.HistoryDir
|
||||
if !gulu.File.IsDir(historyDir) {
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -316,7 +316,7 @@ func syncRepo(byHand bool) {
|
|||
Server: util.AliyunServer,
|
||||
}
|
||||
syncContext := map[string]interface{}{CtxPushMsg: CtxPushMsgToStatusBar}
|
||||
latest, mergeUpserts, mergeRemoves, err := repo.Sync(cloudInfo, syncContext)
|
||||
latest, mergeUpserts, mergeRemoves, _, err := repo.Sync(cloudInfo, syncContext)
|
||||
|
||||
elapsed := time.Since(start)
|
||||
util.LogInfof("sync data repo elapsed [%.2fs], latest [%s]", elapsed.Seconds(), latest.ID)
|
||||
|
|
@ -338,11 +338,11 @@ func syncRepo(byHand bool) {
|
|||
syncSameCount = 5
|
||||
}
|
||||
if !byHand {
|
||||
after := time.Minute * time.Duration(int(math.Pow(2, float64(syncSameCount))))
|
||||
if fixSyncInterval.Minutes() > after.Minutes() {
|
||||
after = time.Minute * 8
|
||||
delay := time.Minute * time.Duration(int(math.Pow(2, float64(syncSameCount))))
|
||||
if fixSyncInterval.Minutes() > delay.Minutes() {
|
||||
delay = time.Minute * 8
|
||||
}
|
||||
planSyncAfter(after)
|
||||
planSyncAfter(delay)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
@ -371,7 +371,7 @@ func syncRepo(byHand bool) {
|
|||
func newRepository() (ret *dejavu.Repo, err error) {
|
||||
ignoreLines := getIgnoreLines()
|
||||
ignoreLines = append(ignoreLines, "/.siyuan/conf.json") // 忽略旧版同步配置
|
||||
ret, err = dejavu.NewRepo(util.DataDir, util.RepoDir, Conf.Repo.Key, ignoreLines)
|
||||
ret, err = dejavu.NewRepo(util.DataDir, util.RepoDir, util.HistoryDir, util.TempDir, Conf.Repo.Key, ignoreLines)
|
||||
if nil != err {
|
||||
util.LogErrorf("init data repository failed: %s", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -196,11 +196,11 @@ func SyncData(boot, exit, byHand bool) {
|
|||
syncSameCount = 5
|
||||
}
|
||||
if !byHand {
|
||||
after := time.Minute * time.Duration(int(math.Pow(2, float64(syncSameCount))))
|
||||
if fixSyncInterval.Minutes() > after.Minutes() {
|
||||
after = time.Minute * 8
|
||||
delay := time.Minute * time.Duration(int(math.Pow(2, float64(syncSameCount))))
|
||||
if fixSyncInterval.Minutes() > delay.Minutes() {
|
||||
delay = time.Minute * 8
|
||||
}
|
||||
planSyncAfter(after)
|
||||
planSyncAfter(delay)
|
||||
}
|
||||
|
||||
Conf.Sync.Stat = Conf.Language(133)
|
||||
|
|
@ -460,6 +460,7 @@ func incReindex(upserts, removes []string) {
|
|||
if !strings.HasSuffix(removeFile, ".sy") {
|
||||
continue
|
||||
}
|
||||
|
||||
id := strings.TrimSuffix(filepath.Base(removeFile), ".sy")
|
||||
block := treenode.GetBlockTree(id)
|
||||
if nil != block {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue