diff --git a/drivers/local/driver.go b/drivers/local/driver.go index a733ebca..e3058618 100644 --- a/drivers/local/driver.go +++ b/drivers/local/driver.go @@ -20,7 +20,7 @@ type Driver struct { Addition } -func (d Driver) Config() driver.Config { +func (d *Driver) Config() driver.Config { return config } @@ -175,7 +175,7 @@ func (d *Driver) Put(ctx context.Context, dstDir model.Obj, stream model.FileStr return nil } -func (d Driver) Other(ctx context.Context, data interface{}) (interface{}, error) { +func (d *Driver) Other(ctx context.Context, data interface{}) (interface{}, error) { return nil, errs.NotSupport } diff --git a/internal/model/storage.go b/internal/model/storage.go index f816b05f..626ab4d5 100644 --- a/internal/model/storage.go +++ b/internal/model/storage.go @@ -27,8 +27,8 @@ type Proxy struct { DownProxyUrl string `json:"down_proxy_url"` } -func (a Storage) GetStorage() Storage { - return a +func (a *Storage) GetStorage() Storage { + return *a } func (a *Storage) SetStatus(status string) { diff --git a/internal/operations/driver.go b/internal/operations/driver.go index 46480f12..7a45e497 100644 --- a/internal/operations/driver.go +++ b/internal/operations/driver.go @@ -54,7 +54,7 @@ func registerDriverItems(config driver.Config, addition driver.Additional) { func getMainItems(config driver.Config) []driver.Item { items := []driver.Item{{ - Name: "virtual_path", + Name: "mount_path", Type: conf.TypeString, Required: true, Help: "", @@ -62,6 +62,9 @@ func getMainItems(config driver.Config) []driver.Item { Name: "index", Type: conf.TypeNumber, Help: "use to sort", + }, { + Name: "remark", + Type: conf.TypeText, }, { Name: "down_proxy_url", Type: conf.TypeText, diff --git a/server/common/req.go b/server/common/req.go index 315b47f0..811c4b8c 100644 --- a/server/common/req.go +++ b/server/common/req.go @@ -5,11 +5,16 @@ type PageReq struct { PageSize int `json:"page_size" form:"page_size"` } +const MaxUint = ^uint(0) +const MinUint = 0 +const MaxInt = int(MaxUint >> 1) +const MinInt = -MaxInt - 1 + func (p *PageReq) Validate() { if p.PageIndex < 1 { p.PageIndex = 1 } if p.PageSize < 1 { - p.PageSize = 50 + p.PageSize = MaxInt } } diff --git a/server/handles/meta.go b/server/handles/meta.go index 0f1929e2..1cfa8d18 100644 --- a/server/handles/meta.go +++ b/server/handles/meta.go @@ -20,6 +20,7 @@ func ListMetas(c *gin.Context) { common.ErrorResp(c, err, 400) return } + req.Validate() log.Debugf("%+v", req) metas, total, err := db.GetMetas(req.PageIndex, req.PageSize) if err != nil { diff --git a/server/handles/account.go b/server/handles/storage.go similarity index 98% rename from server/handles/account.go rename to server/handles/storage.go index 07977b92..9a462262 100644 --- a/server/handles/account.go +++ b/server/handles/storage.go @@ -17,6 +17,7 @@ func ListStorages(c *gin.Context) { common.ErrorResp(c, err, 400) return } + req.Validate() log.Debugf("%+v", req) storages, total, err := db.GetStorages(req.PageIndex, req.PageSize) if err != nil { diff --git a/server/handles/user.go b/server/handles/user.go index dc4aa03b..b3d31df5 100644 --- a/server/handles/user.go +++ b/server/handles/user.go @@ -16,6 +16,7 @@ func ListUsers(c *gin.Context) { common.ErrorResp(c, err, 400) return } + req.Validate() log.Debugf("%+v", req) users, total, err := db.GetUsers(req.PageIndex, req.PageSize) if err != nil {