An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: 支持多设备操作不同文档后云端同步合并 https://github.com/siyuan-note/siyuan/issues/5092
Liang Ding8f42447a023d
diff --git a/kernel/model/osssync.go b/kernel/model/osssync.goindex 6352be4aa7..43a4caac17 100644--- a/kernel/model/osssync.go+++ b/kernel/model/osssync.go@@ -33,6 +33,8 @@ import ("github.com/88250/gulu""github.com/panjf2000/ants/v2""github.com/qiniu/go-sdk/v7/storage"+ "github.com/siyuan-note/siyuan/kernel/sql"+ "github.com/siyuan-note/siyuan/kernel/treenode""github.com/siyuan-note/siyuan/kernel/util")@@ -431,50 +433,50 @@ func ossUpload(isBackup bool, localDirPath, cloudDirPath, cloudDevice string, boif 0 < len(downloadList) && !isBackup {// 下载合并云端变更- //var data []byte- //data, err = gulu.JSON.MarshalJSON(cloudFileList)- //if nil != err {- // return- //}- //indexPath := filepath.Join(util.TempDir, "sync", "index.json")- //if err = os.WriteFile(indexPath, data, 0644); nil != err {- // return- //}- //- //var tmpFetchedFiles int- //var tmpTransferSize uint64- //err = ossDownload0(util.TempDir+"/sync", "sync/"+Conf.Sync.CloudName, "/"+pathJSON, &tmpFetchedFiles, &tmpTransferSize, false)- //if nil != err {- // util.LogErrorf("download merge cloud file failed: %s", err)- //}- //- //metaPath := filepath.Join(util.TempDir, "/sync/"+pathJSON)- //mergeErr := syncDirUpsertWorkspaceData(metaPath, indexPath, downloadList)- //if nil != mergeErr {- // util.LogErrorf("download merge cloud file failed: %s", mergeErr)- //} else {- // // 增量索引- // for upsertFile, _ := range downloadList {- // if !strings.HasSuffix(upsertFile, ".sy") {- // continue- // }- //- // upsertFile = filepath.ToSlash(upsertFile)- // box := upsertFile[:strings.Index(upsertFile, "/")]- // p := strings.TrimPrefix(upsertFile, box)- // tree, err0 := LoadTree(box, p)- // if nil != err0 {- // continue- // }- // treenode.ReindexBlockTree(tree)- // sql.UpsertTreeQueue(tree)- // }- //}- //- //// 重新生成云端索引- //if _, idxErr := genCloudIndex(localDirPath, excludes); nil != idxErr {- // return- //}+ var data []byte+ data, err = gulu.JSON.MarshalJSON(cloudFileList)+ if nil != err {+ return+ }+ indexPath := filepath.Join(util.TempDir, "sync", "index.json")+ if err = os.WriteFile(indexPath, data, 0644); nil != err {+ return+ }++ var tmpFetchedFiles int+ var tmpTransferSize uint64+ err = ossDownload0(util.TempDir+"/sync", "sync/"+Conf.Sync.CloudName, "/"+pathJSON, &tmpFetchedFiles, &tmpTransferSize, false)+ if nil != err {+ util.LogErrorf("download merge cloud file failed: %s", err)+ }++ metaPath := filepath.Join(util.TempDir, "/sync/"+pathJSON)+ mergeErr := syncDirUpsertWorkspaceData(metaPath, indexPath, downloadList)+ if nil != mergeErr {+ util.LogErrorf("download merge cloud file failed: %s", mergeErr)+ } else {+ // 增量索引+ for upsertFile, _ := range downloadList {+ if !strings.HasSuffix(upsertFile, ".sy") {+ continue+ }++ upsertFile = filepath.ToSlash(upsertFile)+ box := upsertFile[:strings.Index(upsertFile, "/")]+ p := strings.TrimPrefix(upsertFile, box)+ tree, err0 := LoadTree(box, p)+ if nil != err0 {+ continue+ }+ treenode.ReindexBlockTree(tree)+ sql.UpsertTreeQueue(tree)+ }+ }++ // 重新生成云端索引+ if _, idxErr := genCloudIndex(localDirPath, excludes); nil != idxErr {+ return+ }}}