Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Add more file formats supporting snapshots comparing https://github.com/siyuan-note/siyuan/issues/8438

Daniel7ebc8f04595b
diff --git a/kernel/api/repo.go b/kernel/api/repo.go
index 7ec3fbd9f1..938bdc6097 100644
--- a/kernel/api/repo.go
+++ b/kernel/api/repo.go
@@ -36,7 +36,7 @@ func openRepoSnapshotDoc(c *gin.Context) {
}
id := arg["id"].(string)
- id, rootID, content, isLargeDoc, updated, err := model.OpenRepoSnapshotDoc(id)
+ content, isLargeDoc, updated, err := model.OpenRepoSnapshotDoc(id)
if nil != err {
ret.Code = -1
ret.Msg = err.Error()
@@ -44,8 +44,6 @@ func openRepoSnapshotDoc(c *gin.Context) {
}
ret.Data = map[string]interface{}{
- "id": id,
- "rootID": rootID,
"content": content,
"isLargeDoc": isLargeDoc,
"updated": updated,
diff --git a/kernel/model/repository.go b/kernel/model/repository.go
index a44b82df75..5a48765e54 100644
--- a/kernel/model/repository.go
+++ b/kernel/model/repository.go
@@ -71,7 +71,7 @@ type TypeCount struct {
Count int `json:"count"`
}
-func OpenRepoSnapshotDoc(fileID string) (id, rootID, content string, isLargeDoc bool, updated int64, err error) {
+func OpenRepoSnapshotDoc(fileID string) (content string, isLargeDoc bool, updated int64, err error) {
if 1 > len(Conf.Repo.Key) {
err = errors.New(Conf.Language(26))
return
@@ -102,8 +102,6 @@ func OpenRepoSnapshotDoc(fileID string) (id, rootID, content string, isLargeDoc
logging.LogErrorf("parse tree from snapshot file [%s] failed", fileID)
return
}
- id = snapshotTree.Root.ID
- rootID = snapshotTree.Root.ID
if !isLargeDoc {
renderTree := &parse.Tree{Root: &ast.Node{Type: ast.NodeDocument}}
@@ -147,7 +145,11 @@ func OpenRepoSnapshotDoc(fileID string) (id, rootID, content string, isLargeDoc
if strings.HasSuffix(file.Path, ".json") {
content = gulu.Str.FromBytes(data)
} else {
- content = file.Path
+ if strings.Contains(file.Path, "assets/") {
+ content = file.Path[strings.Index(file.Path, "assets/"):]
+ } else {
+ content = file.Path
+ }
}
}
return