Skip to content

Commit

Permalink
chore: fix typos
Browse files Browse the repository at this point in the history
Signed-off-by: Rui Chen <[email protected]>
  • Loading branch information
chenrui333 authored and qjfoidnh committed Jan 8, 2025
1 parent dc359ad commit 1a8dab4
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 56 deletions.
4 changes: 2 additions & 2 deletions baidupcs/baidupcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ const (
OperationGetRapidUploadInfo = "获取文件秒传信息"
// OperationFixMD5 修复文件md5
OperationFixMD5 = "修复文件md5"
// OperrationMatchPathByShellPattern 通配符匹配文件路径
OperrationMatchPathByShellPattern = "通配符匹配文件路径"
// OperationMatchPathByShellPattern 通配符匹配文件路径
OperationMatchPathByShellPattern = "通配符匹配文件路径"

// PCSBaiduCom pcs api地址
PCSBaiduCom = "pcs.baidu.com"
Expand Down
2 changes: 1 addition & 1 deletion baidupcs/extends.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ func (pcs *BaiduPCS) recurseMatchPathByShellPattern(index int, patternSlice *[]s

// MatchPathByShellPattern 通配符匹配文件路径, pattern 为绝对路径
func (pcs *BaiduPCS) MatchPathByShellPattern(pattern string) (pcspaths []string, pcsError pcserror.Error) {
errInfo := pcserror.NewPCSErrorInfo(OperrationMatchPathByShellPattern)
errInfo := pcserror.NewPCSErrorInfo(OperationMatchPathByShellPattern)
errInfo.ErrType = pcserror.ErrTypeOthers

patternSlice := strings.Split(escaper.Escape(path.Clean(pattern), []rune{'['}), PathSeparator) // 转义中括号
Expand Down
18 changes: 9 additions & 9 deletions baidupcs/pcserror/pcserror.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,21 @@ const (
)

// DecodePCSJSONError 解析PCS JSON的错误
func DecodePCSJSONError(opreation string, data io.Reader) Error {
errInfo := NewPCSErrorInfo(opreation)
return HandleJSONParse(opreation, data, errInfo)
func DecodePCSJSONError(operation string, data io.Reader) Error {
errInfo := NewPCSErrorInfo(operation)
return HandleJSONParse(operation, data, errInfo)
}

// DecodePanJSONError 解析Pan JSON的错误
func DecodePanJSONError(opreation string, data io.Reader) Error {
errInfo := NewPanErrorInfo(opreation)
return HandleJSONParse(opreation, data, errInfo)
func DecodePanJSONError(operation string, data io.Reader) Error {
errInfo := NewPanErrorInfo(operation)
return HandleJSONParse(operation, data, errInfo)
}

// DecodeXPanJSONError 解析XPan JSON的错误
func DecodeXPanJSONError(opreation string, data io.Reader) Error {
errInfo := NewXPanErrorInfo(opreation)
return HandleJSONParse(opreation, data, errInfo)
func DecodeXPanJSONError(operation string, data io.Reader) Error {
errInfo := NewXPanErrorInfo(operation)
return HandleJSONParse(operation, data, errInfo)
}

// HandleJSONParse 处理解析json
Expand Down
24 changes: 12 additions & 12 deletions baidupcs/prepare.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ func handleRespClose(resp *http.Response) error {
return nil
}

func handleRespStatusError(opreation string, resp *http.Response) pcserror.Error {
//errInfo := pcserror.NewPCSErrorInfo(opreation)
func handleRespStatusError(operation string, resp *http.Response) pcserror.Error {
//errInfo := pcserror.NewPCSErrorInfo(operation)
// http 响应错误处理
switch resp.StatusCode / 100 {
case 4, 5:
errInfo := pcserror.DecodePCSJSONError(opreation, resp.Body)
errInfo := pcserror.DecodePCSJSONError(operation, resp.Body)
resp.Body.Close()
errInfo.SetRemoteError()
//errInfo.SetNetError(fmt.Errorf("http 响应错误, %s", resp.Status))
Expand Down Expand Up @@ -138,7 +138,7 @@ func (pcs *BaiduPCS) PrepareFilesDirectoriesBatchMeta(paths ...string) (dataRead

// 表单上传
mr := multipartreader.NewMultipartReader()
mr.AddFormFeild("param", bytes.NewReader(sendData))
mr.AddFormField("param", bytes.NewReader(sendData))
mr.CloseMultipart()

dataReadCloser, pcsError = pcs.sendReqReturnReadCloser(reqTypePCS, OperationFilesDirectoriesMeta, http.MethodPost, pcsURL.String(), mr, nil)
Expand Down Expand Up @@ -231,7 +231,7 @@ func (pcs *BaiduPCS) PrepareRemove(paths ...string) (dataReadCloser io.ReadClose

// 表单上传
mr := multipartreader.NewMultipartReader()
mr.AddFormFeild("param", bytes.NewReader(sendData))
mr.AddFormField("param", bytes.NewReader(sendData))
mr.CloseMultipart()

dataReadCloser, pcsError = pcs.sendReqReturnReadCloser(reqTypePCS, OperationRemove, http.MethodPost, pcsURL.String(), mr, nil)
Expand Down Expand Up @@ -259,7 +259,7 @@ func (pcs *BaiduPCS) prepareCpMvOp(op string, cpmvJSON ...*CpMvJSON) (dataReadCl
case OperationMove, OperationRename:
method = "move"
default:
panic("Unknown opreation: " + op)
panic("Unknown operation: " + op)
}

sendData, err := (&CpMvListJSON{
Expand All @@ -275,7 +275,7 @@ func (pcs *BaiduPCS) prepareCpMvOp(op string, cpmvJSON ...*CpMvJSON) (dataReadCl

// 表单上传
mr := multipartreader.NewMultipartReader()
mr.AddFormFeild("param", bytes.NewReader(sendData))
mr.AddFormField("param", bytes.NewReader(sendData))
mr.CloseMultipart()

dataReadCloser, pcsError = pcs.sendReqReturnReadCloser(reqTypePCS, op, http.MethodPost, pcsURL.String(), mr, nil)
Expand Down Expand Up @@ -534,7 +534,7 @@ func (pcs *BaiduPCS) PrepareUploadCreateSuperFile(policy string, checkDir bool,

// 表单上传
mr := multipartreader.NewMultipartReader()
mr.AddFormFeild("param", bytes.NewReader(sendData))
mr.AddFormField("param", bytes.NewReader(sendData))
mr.CloseMultipart()

dataReadCloser, pcsError = pcs.sendReqReturnReadCloser(reqTypePCS, OperationUploadCreateSuperFile, http.MethodPost, pcsURL.String(), mr, nil)
Expand Down Expand Up @@ -644,15 +644,15 @@ func (pcs *BaiduPCS) PrepareCloudDlListTask() (dataReadCloser io.ReadCloser, pcs
return
}

func (pcs *BaiduPCS) prepareCloudDlCDTask(opreation, method string, taskID int64) (dataReadCloser io.ReadCloser, pcsError pcserror.Error) {
func (pcs *BaiduPCS) prepareCloudDlCDTask(operation, method string, taskID int64) (dataReadCloser io.ReadCloser, pcsError pcserror.Error) {
pcs.lazyInit()
pcsURL2 := pcs.generatePCSURL2("services/cloud_dl", method, map[string]string{
"app_id": PanAppID,
"task_id": strconv.FormatInt(taskID, 10),
})
baiduPCSVerbose.Infof("%s URL: %s\n", opreation, pcsURL2)
baiduPCSVerbose.Infof("%s URL: %s\n", operation, pcsURL2)

dataReadCloser, pcsError = pcs.sendReqReturnReadCloser(reqTypePCS, opreation, http.MethodPost, pcsURL2.String(), nil, nil)
dataReadCloser, pcsError = pcs.sendReqReturnReadCloser(reqTypePCS, operation, http.MethodPost, pcsURL2.String(), nil, nil)
return
}

Expand Down Expand Up @@ -799,7 +799,7 @@ func (pcs *BaiduPCS) PrepareRecycleRestore(fidList ...int64) (dataReadCloser io.

// 表单上传
mr := multipartreader.NewMultipartReader()
mr.AddFormFeild("param", bytes.NewReader(sendData))
mr.AddFormField("param", bytes.NewReader(sendData))
mr.CloseMultipart()

dataReadCloser, pcsError = pcs.sendReqReturnReadCloser(reqTypePCS, OperationRecycleRestore, http.MethodPost, pcsURL.String(), mr, nil)
Expand Down
4 changes: 2 additions & 2 deletions docs/file_data_apis_error.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
| 403 | 31110 | access denied to set quota | 未授权设置此目录配额 |
| 400 | 31111 | quota only sopport 2 level directories | 配额管理只支持两级目录 |
| 400 | 31112 | exceed quota | 超出配额 |
| 403 | 31113 | the quota is bigger than one of its parent directorys | 配额不能超出目录祖先的配额 |
| 403 | 31114 | the quota is smaller than one of its sub directorys | 配额不能比子目录配额小 |
| 403 | 31113 | the quota is bigger than one of its parent directories | 配额不能超出目录祖先的配额 |
| 403 | 31114 | the quota is smaller than one of its sub directories | 配额不能比子目录配额小 |
| 503 | 31141 | thumbnail failed, internal error | 请求缩略图服务失败 |
| 401 | 110 | Access token invalid or no longer valid | Access Token不正确或者已经过期 |
| 400 | 31201 | signature error | 签名错误 |
Expand Down
4 changes: 2 additions & 2 deletions docs/structured_data_apis_error.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@
| 400 | 31451 | quota size param not exist | 找不到参数quota size ||
| 503 | 31452 | quota info fail | quota info失败 ||
| 400 | 31453 | quota too big | quota过大 ||
| 400 | 31454 | quota size param not numberic | quota size 参数未数值化 ||
| 400 | 31454 | quota size param not numeric | quota size 参数未数值化 ||
| 400 | 31460 | no permission | 未授权 ||
| 400 | 31461 | account not login | 账户为登录,使用bduss认证失败 ||
| 400 | 31462 | access token errro | access token校验失败 ||
| 400 | 31462 | access token error | access token校验失败 ||
| 400 | 31470 | index num too much | index num太多 ||
| 400 | 31472 | table already exist | table已存在 ||
| 400 | 31473 | abnormal table already exist | 异常table已存在 ||
Expand Down
32 changes: 16 additions & 16 deletions internal/pcscommand/cp_mv.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ func runCpMvOp(op string, paths ...string) {
return
}

froms, to := cpmvParsePath(paths...) // 分割
from, to := cpmvParsePath(paths...) // 分割

froms, err = matchPathByShellPattern(froms...)
from, err = matchPathByShellPattern(from...)
if err != nil {
fmt.Println(err)
return
Expand Down Expand Up @@ -58,35 +58,35 @@ func runCpMvOp(op string, paths ...string) {
// 判断路径是否存在
// 如果不存在, 则为重命名或同目录拷贝操作

// 如果 froms 数不是1, 则意义不明确.
if len(froms) != 1 {
// 如果 from 数不是1, 则意义不明确.
if len(from) != 1 {
fmt.Println(err)
return
}

if op == "copy" { // 拷贝
err = pcs.Copy(&baidupcs.CpMvJSON{
From: froms[0],
From: from[0],
To: to,
})
if err != nil {
fmt.Println(err)
fmt.Println("文件/目录拷贝失败: ")
fmt.Printf("%s <-> %s\n", froms[0], to)
fmt.Printf("%s <-> %s\n", from[0], to)
return
}
fmt.Println("文件/目录拷贝成功: ")
fmt.Printf("%s <-> %s\n", froms[0], to)
fmt.Printf("%s <-> %s\n", from[0], to)
} else { // 重命名
err = pcs.Rename(froms[0], path.Clean(to))
err = pcs.Rename(from[0], path.Clean(to))
if err != nil {
fmt.Println(err)
fmt.Println("重命名失败: ")
fmt.Printf("%s -> %s\n", froms[0], to)
fmt.Printf("%s -> %s\n", from[0], to)
return
}
fmt.Println("重命名成功: ")
fmt.Printf("%s -> %s\n", froms[0], to)
fmt.Printf("%s -> %s\n", from[0], to)
}
return
case pcsError != nil && pcsError.GetErrType() != pcserror.ErrTypeRemoteError:
Expand All @@ -100,11 +100,11 @@ func runCpMvOp(op string, paths ...string) {
}

cj := new(baidupcs.CpMvListJSON)
cj.List = make([]*baidupcs.CpMvJSON, len(froms))
for k := range froms {
cj.List = make([]*baidupcs.CpMvJSON, len(from))
for k := range from {
cj.List[k] = &baidupcs.CpMvJSON{
From: froms[k],
To: path.Clean(to + baidupcs.PathSeparator + path.Base(froms[k])),
From: from[k],
To: path.Clean(to + baidupcs.PathSeparator + path.Base(from[k])),
}
}

Expand Down Expand Up @@ -145,11 +145,11 @@ func cpmvPathValid(paths ...string) (err error) {
}

// cpmvParsePath 解析路径
func cpmvParsePath(paths ...string) (froms []string, to string) {
func cpmvParsePath(paths ...string) (from []string, to string) {
if len(paths) == 0 {
return nil, ""
}
froms = paths[:len(paths)-1]
from = paths[:len(paths)-1]
to = paths[len(paths)-1]
return
}
6 changes: 3 additions & 3 deletions pcsutil/converter/converter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
)

func TestTrimPathInvalidChars(t *testing.T) {
trimed := converter.TrimPathInvalidChars("ksjadfi*/?adf")
if strings.Compare(trimed, "ksjadfiadf") != 0 {
t.Fatalf("trimed: %s\n", trimed)
trimmed := converter.TrimPathInvalidChars("ksjadfi*/?adf")
if strings.Compare(trimmed, "ksjadfiadf") != 0 {
t.Fatalf("trimmed: %s\n", trimmed)
}
return
}
2 changes: 1 addition & 1 deletion requester/downloader/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func (mt *Monitor) registerAllCompleted() {
mt.err = worker.Err()
close(mt.completed)
return
case StatusCodeSuccessed, StatusCodeCanceled:
case StatusCodeSucceeded, StatusCodeCanceled:
completeNum++
}
}
Expand Down
6 changes: 3 additions & 3 deletions requester/downloader/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ type (
const (
//StatusCodeInit 初始化
StatusCodeInit StatusCode = iota
//StatusCodeSuccessed 成功
StatusCodeSuccessed
//StatusCodeSucceeded 成功
StatusCodeSucceeded
//StatusCodePending 等待响应
StatusCodePending
//StatusCodeDownloading 下载中
Expand Down Expand Up @@ -55,7 +55,7 @@ func GetStatusText(sc StatusCode) string {
switch sc {
case StatusCodeInit:
return "初始化"
case StatusCodeSuccessed:
case StatusCodeSucceeded:
return "成功"
case StatusCodePending:
return "等待响应"
Expand Down
6 changes: 3 additions & 3 deletions requester/downloader/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func (wer *Worker) Canceled() bool {
//Completed 是否已经完成
func (wer *Worker) Completed() bool {
switch wer.status.statusCode {
case StatusCodeSuccessed, StatusCodeCanceled:
case StatusCodeSucceeded, StatusCodeCanceled:
return true
default:
return false
Expand Down Expand Up @@ -245,7 +245,7 @@ func (wer *Worker) Execute() {
if rlen < 0 {
pcsverbose.Verbosef("DEBUG: RangeLen is negative at begin: %v, %d\n", wer.wrange, wer.wrange.Len())
}
wer.status.statusCode = StatusCodeSuccessed
wer.status.statusCode = StatusCodeSucceeded
return
}
}
Expand Down Expand Up @@ -440,7 +440,7 @@ func (wer *Worker) Execute() {
case rlen <= 0:
// 下载完成
// 小于0可能是因为 worker 被 duplicate
wer.status.statusCode = StatusCodeSuccessed
wer.status.statusCode = StatusCodeSucceeded
if rlen < 0 {
pcsverbose.Verbosef("DEBUG: RangeLen is negative at end: %v, %d\n", wer.wrange, wer.wrange.Len())
}
Expand Down
4 changes: 2 additions & 2 deletions requester/multipartreader/multipartreader.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ func NewMultipartReader() (mr *MultipartReader) {
return
}

// AddFormFeild 增加 form 表单
func (mr *MultipartReader) AddFormFeild(fieldname string, readerlen rio.ReaderLen) {
// AddFormField 增加 form 表单
func (mr *MultipartReader) AddFormField(fieldname string, readerlen rio.ReaderLen) {
if readerlen == nil {
return
}
Expand Down

0 comments on commit 1a8dab4

Please sign in to comment.