Skip to content

Commit

Permalink
update part-size
Browse files Browse the repository at this point in the history
  • Loading branch information
huangnauh committed Feb 11, 2025
1 parent 38d6b20 commit 63fc307
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion session.go
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ func (sess *Session) putFileWithProgress(localPath, upPath string, localInfo os.
}
if localInfo.Size() >= MinResumePutFileSize || sess.multipart {
cfg.UseResumeUpload = true
cfg.ResumePartSize = DefaultBlockSize
cfg.ResumePartSize = ResumePartSize(localInfo.Size())
cfg.MaxResumePutTries = DefaultResumeRetry
}

Expand Down
12 changes: 12 additions & 0 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,18 @@ func isWindowsGOOS() bool {
return runtime.GOOS == "windows"
}

func ResumePartSize(size int64) int64 {
if size < 50*1024*1024 {
return 1024 * 1024
}

if size < 500*1024*1024 {
return 10 * 1024 * 1024
}

return 50 * 1024 * 1024
}

func cleanFilename(name string) string {
if !isWindowsGOOS() {
return name
Expand Down

0 comments on commit 63fc307

Please sign in to comment.