Skip to content

Commit

Permalink
tsest
Browse files Browse the repository at this point in the history
  • Loading branch information
Sunakier committed Nov 18, 2023
1 parent 867acca commit 749570a
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 31 deletions.
2 changes: 1 addition & 1 deletion drivers/teambition/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (d *Teambition) Link(ctx context.Context, file model.Obj, args model.LinkAr
}
return &model.Link{URL: url}, nil
}
return nil, errors.New("can't convert obj to URL")
return nil, errors.New("无法将对象转换为链接")
}

func (d *Teambition) MakeDir(ctx context.Context, parentDir model.Obj, dirName string) error {
Expand Down
7 changes: 4 additions & 3 deletions drivers/teambition/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import (
)

type Addition struct {
Region string `json:"region" type:"select" options:"china,international" required:"true"`
Cookie string `json:"cookie" required:"true"`
ProjectID string `json:"project_id" required:"true"`
Region string `json:"region" type:"select" options:"china,international" required:"true"`
Cookie string `json:"cookie" required:"true"`
ProjectID string `json:"project_id" required:"true"`
UseProxyGet bool `json:"use_proxy_get" required:"false" default:"true"`
driver.RootID
OrderBy string `json:"order_by" type:"select" options:"fileName,fileSize,updated,created" default:"fileName"`
OrderDirection string `json:"order_direction" type:"select" options:"Asc,Desc" default:"Asc"`
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ github.com/andreburgaud/crypt2go v1.2.0/go.mod h1:kKRqlrX/3Q9Ki7HdUsoh0cX1Urq14/
github.com/avast/retry-go v3.0.0+incompatible h1:4SOWQ7Qs+oroOTQOYnAHqelpCO0biHSxpiH9JdtuBj0=
github.com/avast/retry-go v3.0.0+incompatible/go.mod h1:XtSnn+n/sHqQIpZ10K1qAevBhOOCWBLXXy3hyiqqBrY=
github.com/aws/aws-sdk-go v1.38.20/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro=
github.com/aws/aws-sdk-go v1.44.327 h1:ZS8oO4+7MOBLhkdwIhgtVeDzCeWOlTfKJS7EgggbIEY=
github.com/aws/aws-sdk-go v1.44.327/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI=
github.com/aws/aws-sdk-go v1.46.7 h1:IjvAWeiJZlbETOemOwvheN5L17CvKvKW0T1xOC6d3Sc=
github.com/aws/aws-sdk-go v1.46.7/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI=
github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
Expand Down
2 changes: 1 addition & 1 deletion internal/errs/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ package errs
import "errors"

var (
EmptyToken = errors.New("empty token")
EmptyToken = errors.New("Token为空")
)
18 changes: 9 additions & 9 deletions internal/errs/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ import (
)

var (
NotImplement = errors.New("not implement")
NotSupport = errors.New("not support")
RelativePath = errors.New("access using relative path is not allowed")
NotImplement = errors.New("未实现")
NotSupport = errors.New("不支持")
RelativePath = errors.New("不允许使用相对路径访问")

MoveBetweenTwoStorages = errors.New("can't move files between two storages, try to copy")
UploadNotSupported = errors.New("upload not supported")
MoveBetweenTwoStorages = errors.New("无法跨存储移动, 尝试复制")
UploadNotSupported = errors.New("不支持上传")

MetaNotFound = errors.New("meta not found")
StorageNotFound = errors.New("storage not found")
StreamIncomplete = errors.New("upload/download stream incomplete, possible network issue")
StreamPeekFail = errors.New("StreamPeekFail")
MetaNotFound = errors.New("元数据未找到")
StorageNotFound = errors.New("存储未找到")
StreamIncomplete = errors.New("上传/下载流不完整, 可能是网络问题")
StreamPeekFail = errors.New("流查看失败")
)

// NewErr wrap constant error with an extra message
Expand Down
6 changes: 3 additions & 3 deletions internal/errs/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
)

var (
ObjectNotFound = errors.New("object not found")
NotFolder = errors.New("not a folder")
NotFile = errors.New("not a file")
ObjectNotFound = errors.New("找不到对象")
NotFolder = errors.New("这不是一个文件夹")
NotFile = errors.New("这不是一个文件")
)

func IsObjectNotFound(err error) bool {
Expand Down
2 changes: 1 addition & 1 deletion internal/errs/operate.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ package errs
import "errors"

var (
PermissionDenied = errors.New("permission denied")
PermissionDenied = errors.New("无权限")
)
2 changes: 1 addition & 1 deletion internal/errs/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ package errs
import "fmt"

var (
SearchNotAvailable = fmt.Errorf("search not available")
SearchNotAvailable = fmt.Errorf("搜索不可用")
)
8 changes: 4 additions & 4 deletions internal/errs/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package errs
import "errors"

var (
EmptyUsername = errors.New("username is empty")
EmptyPassword = errors.New("password is empty")
WrongPassword = errors.New("password is incorrect")
DeleteAdminOrGuest = errors.New("cannot delete admin or guest")
EmptyUsername = errors.New("用户名为空")
EmptyPassword = errors.New("密码为空")
WrongPassword = errors.New("密码不正确")
DeleteAdminOrGuest = errors.New("无法删除admin用户或者guest用户")
)
10 changes: 5 additions & 5 deletions server/common/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,18 @@ func ParseToken(tokenString string) (*UserClaims, error) {
if err != nil {
if ve, ok := err.(*jwt.ValidationError); ok {
if ve.Errors&jwt.ValidationErrorMalformed != 0 {
return nil, errors.New("that's not even a token")
return nil, errors.New("Token不可用")
} else if ve.Errors&jwt.ValidationErrorExpired != 0 {
return nil, errors.New("token is expired")
return nil, errors.New("Token已过期")
} else if ve.Errors&jwt.ValidationErrorNotValidYet != 0 {
return nil, errors.New("token not active yet")
return nil, errors.New("Token尚未激活")
} else {
return nil, errors.New("couldn't handle this token")
return nil, errors.New("无法处理此Token")
}
}
}
if claims, ok := token.Claims.(*UserClaims); ok && token.Valid {
return claims, nil
}
return nil, errors.New("couldn't handle this token")
return nil, errors.New("无法处理此Token")
}
2 changes: 1 addition & 1 deletion server/handles/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func loginHash(c *gin.Context, req *LoginReq) {
ip := c.ClientIP()
count, ok := loginCache.Get(ip)
if ok && count >= defaultTimes {
common.ErrorStrResp(c, "Too many unsuccessful sign-in attempts have been made using an incorrect username or password, Try again later.", 429)
common.ErrorStrResp(c, "你的登录请求已被服务器拦截, 请稍后再试", 429)
loginCache.Expire(ip, defaultDuration)
return
}
Expand Down

0 comments on commit 749570a

Please sign in to comment.