* feat: remove index on `SearchNode.Name` As we do not use s% on name column, index there does not work * fix: init index after init data Or on the first run, it will log 'init index error: readObjectStart: expect { or n, but found , error found in #0 byte of ...||..., bigger context ...||...' * fix: match parent more precisely It will match `/a/bc` if we search in `/a/b` originally. But it is not backward compatible by adding a suffix `/` to all the data in parent field
41 lines
750 B
Go
41 lines
750 B
Go
package model
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
)
|
|
|
|
type IndexProgress struct {
|
|
ObjCount uint64 `json:"obj_count"`
|
|
IsDone bool `json:"is_done"`
|
|
LastDoneTime *time.Time `json:"last_done_time"`
|
|
Error string `json:"error"`
|
|
}
|
|
|
|
type SearchReq struct {
|
|
Parent string `json:"parent"`
|
|
Keywords string `json:"keywords"`
|
|
PageReq
|
|
}
|
|
|
|
type SearchNode struct {
|
|
Parent string `json:"parent" gorm:"index"`
|
|
Name string `json:"name"`
|
|
IsDir bool `json:"is_dir"`
|
|
Size int64 `json:"size"`
|
|
}
|
|
|
|
func (p *SearchReq) Validate() error {
|
|
if p.Page < 1 {
|
|
return fmt.Errorf("page can't < 1")
|
|
}
|
|
if p.PerPage < 1 {
|
|
return fmt.Errorf("per_page can't < 1")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (s *SearchNode) Type() string {
|
|
return "SearchNode"
|
|
}
|