Browse Source

Merge remote-tracking branch 'origin/dev' into dev

Vanessa 1 year ago
parent
commit
53f6030a56
2 changed files with 26 additions and 2 deletions
  1. 4 0
      kernel/model/file.go
  2. 22 2
      kernel/model/session.go

+ 4 - 0
kernel/model/file.go

@@ -1199,6 +1199,7 @@ func GetFullHPathByID(id string) (hPath string, err error) {
 }
 
 func GetIDsByHPath(hpath, boxID string) (ret []string, err error) {
+	ret = []string{}
 	roots := treenode.GetBlockTreeRootsByHPath(boxID, hpath)
 	if 1 > len(roots) {
 		return
@@ -1208,6 +1209,9 @@ func GetIDsByHPath(hpath, boxID string) (ret []string, err error) {
 		ret = append(ret, root.ID)
 	}
 	ret = gulu.Str.RemoveDuplicatedElem(ret)
+	if 1 > len(ret) {
+		ret = []string{}
+	}
 	return
 }
 

+ 22 - 2
kernel/model/session.go

@@ -331,11 +331,31 @@ func ControlConcurrency(c *gin.Context) {
 		return
 	}
 
+	reqPath := c.Request.URL.Path
+
+	// Improve the concurrency of the kernel data reading interfaces https://github.com/siyuan-note/siyuan/issues/10149
+	if strings.HasPrefix(reqPath, "/stage/") || strings.HasPrefix(reqPath, "/assets/") || strings.HasPrefix(reqPath, "/appearance/") {
+		c.Next()
+		return
+	}
+
+	parts := strings.Split(reqPath, "/")
+	function := parts[len(parts)-1]
+	if strings.HasPrefix(function, "get") || strings.HasPrefix(function, "list") ||
+		strings.HasPrefix(function, "search") || strings.HasPrefix(function, "render") || strings.HasPrefix(function, "ls") {
+		c.Next()
+		return
+	}
+	if strings.HasPrefix(function, "/api/query/") || strings.HasPrefix(function, "/api/search/") {
+		c.Next()
+		return
+	}
+
 	requestingLock.Lock()
-	mutex := requesting[c.Request.URL.Path]
+	mutex := requesting[reqPath]
 	if nil == mutex {
 		mutex = &sync.Mutex{}
-		requesting[c.Request.URL.Path] = mutex
+		requesting[reqPath] = mutex
 	}
 	requestingLock.Unlock()