Skip to content

Commit

Permalink
Merge 18ef35d into b89e79f
Browse files Browse the repository at this point in the history
  • Loading branch information
kkuai committed Mar 8, 2019
2 parents b89e79f + 18ef35d commit df40469
Show file tree
Hide file tree
Showing 12 changed files with 2,248 additions and 51 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ install:
- go get github.com/alyu/configparser
- go get github.com/aliyun/aliyun-oss-go-sdk/oss
- go get github.com/syndtr/goleveldb/leveldb
- go get github.com/satori/go.uuid
script:
- cd lib
- travis_wait 120 go test -v -timeout 120m -covermode=count -coverprofile=coverage.out
Expand Down
35 changes: 33 additions & 2 deletions lib/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"net/http"
"strconv"
"strings"
"time"

oss "github.com/aliyun/aliyun-oss-go-sdk/oss"
)
Expand Down Expand Up @@ -300,6 +301,21 @@ func (cmd *Command) ossClient(bucket string) (*oss.Client, error) {
if err != nil {
return nil, err
}

maxUpSpeed, errUp := GetInt(OptionMaxUpSpeed, cmd.options)
if errUp == nil {
if maxUpSpeed >= 0 {
errUp = client.LimitUploadSpeed(int(maxUpSpeed))
if errUp != nil {
return nil, errUp
} else {
LogInfo("set maxupspeed success,value is %d(KB/s)\n", maxUpSpeed)
}
} else {
return nil, fmt.Errorf("invalid value,maxupspeed %d less than 0", maxUpSpeed)
}
}

return client, nil
}

Expand Down Expand Up @@ -380,9 +396,16 @@ func (cmd *Command) ossGetObjectStatRetry(bucket *oss.Bucket, object string, opt
if err == nil {
return props, err
}
if int64(i) >= retryTimes {

// http 4XX 、5XX error no need to retry
// only network error need to retry
_, noNeedRetry := err.(oss.ServiceError)
if int64(i) >= retryTimes || noNeedRetry {
return props, ObjectError{err, bucket.BucketName, object}
}

// wait 1 second
time.Sleep(time.Duration(1) * time.Second)
}
}

Expand All @@ -393,9 +416,16 @@ func (cmd *Command) ossGetObjectMetaRetry(bucket *oss.Bucket, object string, opt
if err == nil {
return props, err
}
if int64(i) >= retryTimes {

// http 4XX 、5XX error no need to retry
// only network error need to retry
_, noNeedRetry := err.(oss.ServiceError)
if int64(i) >= retryTimes || noNeedRetry {
return props, ObjectError{err, bucket.BucketName, object}
}

// wait 1 second
time.Sleep(time.Duration(1) * time.Second)
}
}

Expand Down Expand Up @@ -525,5 +555,6 @@ func GetAllCommands() []interface{} {
&signURLCommand,
&hashCommand,
&updateCommand,
&probeCommand,
}
}
14 changes: 12 additions & 2 deletions lib/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ const (
OptionMeta = "meta"
OptionRequestPayer = "payer"
OptionLogLevel = "loglevel"
OptionMaxUpSpeed = "maxupspeed"
OptionUpload = "upload"
OptionDownload = "download"
OptionUrl = "url"
OptionBucketName = "bucketname"
OptionObject = "object"
OptionAddr = "addr"
OptionUpMode = "upmode"
)

// the elements show in stat object
Expand Down Expand Up @@ -76,9 +84,11 @@ const (
updateEndpoint string = "oss-cn-hangzhou.aliyuncs.com"
updateBucket = "ossutil-version-update"
updateVersionObject = "ossutilversion"
updateBinaryLinux = "ossutil"
updateBinaryLinux32 = "ossutil32"
updateBinaryLinux64 = "ossutil64"
updateBinaryWindow32 = "ossutil32.exe"
updateBinaryWindow64 = "ossutil64.exe"
updateBinaryMac32 = "ossutilmac32"
updateBinaryMac64 = "ossutilmac64"
updateTmpVersionFile = ".ossutil_tmp_vsersion"
)
Expand All @@ -87,7 +97,7 @@ const (
const (
Package string = "ossutil"
ChannelBuf int = 1000
Version string = "1.4.3"
Version string = "1.5.0"
DefaultEndpoint string = "oss.aliyuncs.com"
ChineseLanguage = "CH"
EnglishLanguage = "EN"
Expand Down
1 change: 1 addition & 0 deletions lib/cp.go
Original file line number Diff line number Diff line change
Expand Up @@ -1132,6 +1132,7 @@ var copyCommand = CopyCommand{
OptionDisableCRC64,
OptionRequestPayer,
OptionLogLevel,
OptionMaxUpSpeed,
},
},
}
Expand Down

0 comments on commit df40469

Please sign in to comment.