Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alist-org
GitHub Repository: alist-org/alist
Path: blob/main/internal/model/search.go
1560 views
1
package model
2
3
import (
4
"fmt"
5
"time"
6
)
7
8
type IndexProgress struct {
9
ObjCount uint64 `json:"obj_count"`
10
IsDone bool `json:"is_done"`
11
LastDoneTime *time.Time `json:"last_done_time"`
12
Error string `json:"error"`
13
}
14
15
type SearchReq struct {
16
Parent string `json:"parent"`
17
Keywords string `json:"keywords"`
18
// 0 for all, 1 for dir, 2 for file
19
Scope int `json:"scope"`
20
PageReq
21
}
22
23
type SearchNode struct {
24
Parent string `json:"parent" gorm:"index"`
25
Name string `json:"name"`
26
IsDir bool `json:"is_dir"`
27
Size int64 `json:"size"`
28
}
29
30
func (p *SearchReq) Validate() error {
31
if p.Page < 1 {
32
return fmt.Errorf("page can't < 1")
33
}
34
if p.PerPage < 1 {
35
return fmt.Errorf("per_page can't < 1")
36
}
37
return nil
38
}
39
40
func (s *SearchNode) Type() string {
41
return "SearchNode"
42
}
43
44