Skip to content

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

:art: https://github.com/siyuan-note/siyuan/issues/17410

Daniela6e4b12ea31a
diff --git a/kernel/model/history.go b/kernel/model/history.go
index 6906febeac..9b1d7810ed 100644
--- a/kernel/model/history.go
+++ b/kernel/model/history.go
@@ -149,6 +149,7 @@ func ClearWorkspaceHistory() (err error) {
}
func GetDocHistoryContent(historyPath, keyword string, highlight bool) (id, rootID, content string, isLargeDoc bool, err error) {
+ historyPath = filepath.Join(util.WorkspaceDir, historyPath)
if !util.IsAbsPathInWorkspace(historyPath) {
msg := "Path [" + historyPath + "] is not in workspace"
logging.LogErrorf(msg)
@@ -228,6 +229,7 @@ func GetDocHistoryContent(historyPath, keyword string, highlight bool) (id, root
}
func RollbackDocHistory(historyPath string) (err error) {
+ historyPath = filepath.Join(util.WorkspaceDir, historyPath)
if !gulu.File.IsExist(historyPath) {
logging.LogWarnf("doc history [%s] not exist", historyPath)
return
@@ -432,6 +434,7 @@ func RollbackAssetsHistory(historyPath string) (err error) {
}
func RollbackNotebookHistory(historyPath string) (err error) {
+ historyPath = filepath.Join(util.WorkspaceDir, historyPath)
if !gulu.File.IsExist(historyPath) {
logging.LogWarnf("notebook history [%s] not exist", historyPath)
return
@@ -451,6 +454,7 @@ func RollbackNotebookHistory(historyPath string) (err error) {
}
func RollbackAttributeViewHistory(historyPath string) (err error) {
+ historyPath = filepath.Join(util.WorkspaceDir, historyPath)
if !gulu.File.IsExist(historyPath) {
logging.LogWarnf("av history [%s] not exist", historyPath)
return
@@ -621,7 +625,7 @@ func GetNotebookHistory() (ret []*History, err error) {
HCreated: t,
Items: []*HistoryItem{{
Title: c.Name,
- Path: filepath.Dir(filepath.Dir(historyNotebookConf)),
+ Path: filepath.ToSlash(strings.TrimPrefix(filepath.Dir(filepath.Dir(historyNotebookConf)), util.WorkspaceDir)),
Op: HistoryOpDelete,
}},
})
@@ -1020,12 +1024,10 @@ func fromSQLHistories(sqlHistories []*sql.History) (ret []*HistoryItem) {
for _, sqlHistory := range sqlHistories {
item := &HistoryItem{
Title: sqlHistory.Title,
- Path: filepath.Join(util.HistoryDir, sqlHistory.Path),
+ Path: filepath.ToSlash(strings.TrimPrefix(filepath.Join(util.HistoryDir, sqlHistory.Path), util.WorkspaceDir)),
Op: sqlHistory.Op,
}
- if HistoryTypeAsset == sqlHistory.Type {
- item.Path = filepath.ToSlash(strings.TrimPrefix(item.Path, util.WorkspaceDir))
- } else {
+ if HistoryTypeAsset != sqlHistory.Type {
parts := strings.Split(sqlHistory.Path, "/")
if 2 <= len(parts) {
item.Notebook = parts[1]