Skip to content

Commit

Permalink
v0.1.9 - 避免错误文件的使用
Browse files Browse the repository at this point in the history
  • Loading branch information
spiritysdx committed Jan 27, 2025
1 parent 615ffca commit 2f5feac
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.23.4
require (
github.com/imroc/req/v3 v3.49.0
github.com/oneclickvirt/CommonMediaTests v0.0.4-20240704024502
github.com/oneclickvirt/UnlockTests v0.0.23-20250118070445
github.com/oneclickvirt/UnlockTests v0.0.24-20250127123509
github.com/oneclickvirt/backtrace v0.0.4-20240702140722
github.com/oneclickvirt/basics v0.0.8-20241108124433
github.com/oneclickvirt/cputest v0.0.9-20250103063414
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ github.com/nxtrace/NTrace-core v1.3.7 h1:ZnTbPrPqpyeraCvUyNbQTNyl4Gz3NRQDh06WdII
github.com/nxtrace/NTrace-core v1.3.7/go.mod h1:aW2owz9I+W5i+gJEDmnWli75mB+fuO4UTwdOPMcQHpE=
github.com/oneclickvirt/CommonMediaTests v0.0.4-20240704024502 h1:hRIYJ2uEp2N3AH5bP5X6bwfdwWfZQO/2WoqpUJ8+WsY=
github.com/oneclickvirt/CommonMediaTests v0.0.4-20240704024502/go.mod h1:DAmFPRjFV5p9fEzUUSml5jJGn2f1NZJQCzTxITHDjc4=
github.com/oneclickvirt/UnlockTests v0.0.23-20250118070445 h1:lQmYC12cbE6kMNs+onwS+aC+34aXQToSiAf+oOXweBc=
github.com/oneclickvirt/UnlockTests v0.0.23-20250118070445/go.mod h1:yXWIZB6iLS88pEd9m4QJi1GENn+7I91zA72y5ONz2Oc=
github.com/oneclickvirt/UnlockTests v0.0.24-20250127123509 h1:QTm/2r+0tKOibglvj/W9RhEqp0sciU916wIZ/xOX6qQ=
github.com/oneclickvirt/UnlockTests v0.0.24-20250127123509/go.mod h1:yXWIZB6iLS88pEd9m4QJi1GENn+7I91zA72y5ONz2Oc=
github.com/oneclickvirt/backtrace v0.0.4-20240702140722 h1:UJ/VWf+ZbhGarc9HcHMIyenpmX+b2LxkXu0hlLk3Gxs=
github.com/oneclickvirt/backtrace v0.0.4-20240702140722/go.mod h1:zvsC7xY/WZqs5KL2JB967OVnuqjNbxu9bW6wXRLo5h8=
github.com/oneclickvirt/basics v0.0.8-20241108124433 h1:eKZcoNoa9uLWmfisk+qN/QOvSGT4ajCmZdZfIAcHG+o=
Expand Down
2 changes: 1 addition & 1 deletion goecs.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import (
)

var (
ecsVersion = "v0.1.8"
ecsVersion = "v0.1.9"
menuMode bool
onlyChinaTest bool
input, choice string
Expand Down
12 changes: 12 additions & 0 deletions utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,21 @@ func UploadText(absPath string) (string, string, error) {
SetRetryCount(2).
SetRetryBackoffInterval(1*time.Second, 5*time.Second).
SetRetryFixedInterval(2 * time.Second)
// 打开文件
file, err := os.Open(absPath)
if err != nil {
return "", "", fmt.Errorf("failed to open file: %w", err)
}
defer file.Close()
// 获取文件信息并检查大小
fileInfo, err := file.Stat()
if err != nil {
return "", "", fmt.Errorf("failed to get file info: %w", err)
}
if fileInfo.Size() > 25*1024 { // 25KB
return "", "", fmt.Errorf("file size exceeds 25KB limit")
}
// 上传逻辑
upload := func(url string) (string, string, error) {
file, err := os.Open(absPath)
if err != nil {
Expand Down Expand Up @@ -288,10 +298,12 @@ func UploadText(absPath string) (string, string, error) {
}
return "", "", fmt.Errorf("upload failed for %s with status code: %d", url, resp.StatusCode)
}
// 尝试上传到主URL
httpURL, httpsURL, err := upload(primaryURL)
if err == nil {
return httpURL, httpsURL, nil
}
// 尝试上传到备份URL
httpURL, httpsURL, err = upload(backupURL)
if err != nil {
return "", "", fmt.Errorf("failed to upload to both primary and backup URLs: %w", err)
Expand Down

0 comments on commit 2f5feac

Please sign in to comment.