mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-02 13:41:48 +01:00
🎨 云端同步冲突时支持设置是否产生冲突文档 https://github.com/siyuan-note/siyuan/issues/6110
This commit is contained in:
parent
6e7e154a3c
commit
698f773ee2
9 changed files with 43 additions and 9 deletions
|
|
@ -108,6 +108,19 @@ func createCloudSyncDir(c *gin.Context) {
|
|||
}
|
||||
}
|
||||
|
||||
func setSyncGenerateConflictDoc(c *gin.Context) {
|
||||
ret := gulu.Ret.NewResult()
|
||||
defer c.JSON(http.StatusOK, ret)
|
||||
|
||||
arg, ok := util.JsonArg(c, ret)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
enabled := arg["enabled"].(bool)
|
||||
model.SetSyncGenerateConflictDoc(enabled)
|
||||
}
|
||||
|
||||
func setSyncEnable(c *gin.Context) {
|
||||
ret := gulu.Ret.NewResult()
|
||||
defer c.JSON(http.StatusOK, ret)
|
||||
|
|
|
|||
|
|
@ -17,17 +17,19 @@
|
|||
package conf
|
||||
|
||||
type Sync struct {
|
||||
CloudName string `json:"cloudName"` // 云端同步目录名称
|
||||
Enabled bool `json:"enabled"` // 是否开启同步
|
||||
Mode int `json:"mode"` // 同步模式,0:未设置(为兼容已有配置,initConf 函数中会转换为 1),1:自动,2:手动 https://github.com/siyuan-note/siyuan/issues/5089
|
||||
Synced int64 `json:"synced"` // 最近同步时间
|
||||
Stat string `json:"stat"` // 最近同步统计信息
|
||||
CloudName string `json:"cloudName"` // 云端同步目录名称
|
||||
Enabled bool `json:"enabled"` // 是否开启同步
|
||||
Mode int `json:"mode"` // 同步模式,0:未设置(为兼容已有配置,initConf 函数中会转换为 1),1:自动,2:手动 https://github.com/siyuan-note/siyuan/issues/5089
|
||||
Synced int64 `json:"synced"` // 最近同步时间
|
||||
Stat string `json:"stat"` // 最近同步统计信息
|
||||
GenerateConflictDoc bool `json:"generateConflictDoc"` // 云端同步冲突时是否生成冲突文档
|
||||
}
|
||||
|
||||
func NewSync() *Sync {
|
||||
return &Sync{
|
||||
CloudName: "main",
|
||||
Enabled: false,
|
||||
Mode: 1,
|
||||
CloudName: "main",
|
||||
Enabled: false,
|
||||
Mode: 1,
|
||||
GenerateConflictDoc: false,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -541,7 +541,7 @@ func syncRepo(boot, exit, byHand bool) (err error) {
|
|||
|
||||
logSyncMergeResult(mergeResult)
|
||||
|
||||
if 0 < len(mergeResult.Conflicts) {
|
||||
if 0 < len(mergeResult.Conflicts) && Conf.Sync.GenerateConflictDoc {
|
||||
// 云端同步发生冲突时生成副本 https://github.com/siyuan-note/siyuan/issues/5687
|
||||
|
||||
luteEngine := NewLute()
|
||||
|
|
|
|||
|
|
@ -216,6 +216,15 @@ func SetCloudSyncDir(name string) {
|
|||
Conf.Save()
|
||||
}
|
||||
|
||||
func SetSyncGenerateConflictDoc(b bool) {
|
||||
syncLock.Lock()
|
||||
defer syncLock.Unlock()
|
||||
|
||||
Conf.Sync.GenerateConflictDoc = b
|
||||
Conf.Save()
|
||||
return
|
||||
}
|
||||
|
||||
func SetSyncEnable(b bool) (err error) {
|
||||
syncLock.Lock()
|
||||
defer syncLock.Unlock()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue