Skip to content

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

:bug: Load database data from document snapshots in comparison https://github.com/siyuan-note/siyuan/issues/11601

Danielca1ffce3bf54
diff --git a/kernel/api/history.go b/kernel/api/history.go
index 5558ffbea3..563c6651fc 100644
--- a/kernel/api/history.go
+++ b/kernel/api/history.go
@@ -216,15 +216,16 @@ func diffDocVersions(c *gin.Context) {
}
func parseDocVersionRef(arg map[string]interface{}, ret *gulu.Result) (ref *model.DocVersionRef, ok bool) {
- var typ, id, path string
+ var typ, id, path, snapshot string
if !util.ParseJsonArgs(arg, ret,
util.BindJsonArg("type", &typ, true, true),
util.BindJsonArg("id", &id, false, false),
util.BindJsonArg("path", &path, false, false),
+ util.BindJsonArg("snapshot", &snapshot, false, false),
) {
return nil, false
}
- return &model.DocVersionRef{Type: typ, ID: id, Path: path}, true
+ return &model.DocVersionRef{Type: typ, ID: id, Path: path, Snapshot: snapshot}, true
}
func rollbackDocHistory(c *gin.Context) {
diff --git a/kernel/api/history_test.go b/kernel/api/history_test.go
new file mode 100644
index 0000000000..c7b1eab751
--- /dev/null
+++ b/kernel/api/history_test.go
@@ -0,0 +1,30 @@
+// SiYuan - Refactor your thinking
+// Copyright (c) 2020-present, b3log.org
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+package api
+
+import (
+ "testing"
+
+ "github.com/88250/gulu"
+)
+
+func TestParseDocVersionRefIncludesSnapshot(t *testing.T) {
+ const snapshot = "6b7f54c510e8de12be6e446494987c846f13cd0d"
+ ref, ok := parseDocVersionRef(map[string]interface{}{
+ "type": "snapshot",
+ "id": "1c2971f02672edbc0d2ec6160df7c9c9a18d7402",
+ "snapshot": snapshot,
+ }, gulu.Ret.NewResult())
+ if !ok {
+ t.Fatal("expected document version reference parsing to succeed")
+ }
+ if snapshot != ref.Snapshot {
+ t.Fatalf("expected snapshot [%s], got [%s]", snapshot, ref.Snapshot)
+ }
+}