mirror of
https://github.com/datarhei/core.git
synced 2025-09-26 20:11:29 +08:00
Add process id and reference glob pattern matching
For the API endpoint /v3/process two new query parameter are introduced in order to list only processes that match a pattern for the id and the reference: idpattern and refpattern. The pattern is a glob pattern. If patterns for both are given, the results will be intersected. If you use other query parameters such as id or reference, they will be applied after the result of the pattern matching.
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/datarhei/core/v16/glob"
|
||||
"github.com/datarhei/core/v16/log"
|
||||
)
|
||||
|
||||
@@ -296,7 +297,7 @@ func (fs *diskFilesystem) List(pattern string) []FileInfo {
|
||||
}
|
||||
|
||||
if len(pattern) != 0 {
|
||||
if ok, _ := filepath.Match(pattern, name); !ok {
|
||||
if ok, _ := glob.Match(pattern, name, '/'); !ok {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
@@ -4,11 +4,11 @@ import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/datarhei/core/v16/glob"
|
||||
"github.com/datarhei/core/v16/log"
|
||||
)
|
||||
|
||||
@@ -427,7 +427,7 @@ func (fs *memFilesystem) List(pattern string) []FileInfo {
|
||||
|
||||
for _, file := range fs.files {
|
||||
if len(pattern) != 0 {
|
||||
if ok, _ := filepath.Match(pattern, file.name); !ok {
|
||||
if ok, _ := glob.Match(pattern, file.name, '/'); !ok {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user