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/16149

Daniel0ffa864c8f54
diff --git a/kernel/model/session.go b/kernel/model/session.go
index 82b76d5595..e0fef0d033 100644
--- a/kernel/model/session.go
+++ b/kernel/model/session.go
@@ -181,7 +181,7 @@ func GetCaptcha(c *gin.Context) {
}
func CheckReadonly(c *gin.Context) {
- if util.ReadOnly {
+ if util.ReadOnly || IsReadOnlyRole(GetGinContextRole(c)) {
result := util.NewResult()
result.Code = -1
result.Msg = Conf.Language(34)
diff --git a/kernel/model/storage.go b/kernel/model/storage.go
index 377e933612..1877393430 100644
--- a/kernel/model/storage.go
+++ b/kernel/model/storage.go
@@ -362,10 +362,6 @@ func GetLocalStorage() (ret map[string]interface{}) {
}
func setLocalStorage(val interface{}) (err error) {
- if util.ReadOnly {
- return
- }
-
dirPath := filepath.Join(util.DataDir, "storage")
if err = os.MkdirAll(dirPath, 0755); err != nil {
logging.LogErrorf("create storage [local] dir failed: %s", err)
@@ -437,7 +433,7 @@ func SetOutlineStorage(docID string, val interface{}) (err error) {
DocID: docID,
Data: make(map[string]interface{}),
}
-
+
if valMap, ok := val.(map[string]interface{}); ok {
outlineDoc.Data = valMap
}
@@ -457,7 +453,7 @@ func SetOutlineStorage(docID string, val interface{}) (err error) {
// 将新的文档信息添加到最前面
outlineDocs = append([]*OutlineDoc{outlineDoc}, outlineDocs...)
-
+
// 限制为2000个文档
if 2000 < len(outlineDocs) {
outlineDocs = outlineDocs[:2000]