Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,10 @@ func (cmd *Command) updateMonitor(err error, monitor *Monitor) {
} else {
monitor.updateErrNum(1)
}
fmt.Printf(monitor.progressBar(false, normalExit))
onlyShowErrors, _ := GetBool(OptionOnlyShowErrors, cmd.options)
if !onlyShowErrors {
fmt.Printf(monitor.progressBar(false, normalExit))
}
}

func (cmd *Command) report(msg string, err error, option *batchOptionType) {
Expand Down
8 changes: 6 additions & 2 deletions lib/command_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,13 @@ func ParseAndRunCommand() error {
LogError("%s.\n", err.Error())
return err
}
onlyShowErrors, _ := GetBool(OptionOnlyShowErrors, options)
if showElapse {
te := time.Now().UnixNano()
fmt.Printf("\n%.6f(s) elapsed\n", float64(te-ts)/1e9)
if !onlyShowErrors {
te := time.Now().UnixNano()
fmt.Printf("\n%.6f(s) elapsed\n", float64(te-ts)/1e9)
}

return nil
}
return nil
Expand Down
1 change: 1 addition & 0 deletions lib/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ const (
OptionCloudBoxID = "cloudBoxID"
OptionQueryParam = "queryParam"
OptionForcePathStyle = "forcePathStyle"
OptionOnlyShowErrors = "onlyShowErrors"
OptionRuntime = "runtime"
)

Expand Down
52 changes: 38 additions & 14 deletions lib/cp.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ type copyOptionType struct {
onlyCurrentDir bool
disableDirObject bool
disableAllSymlink bool
onlyShowErrors bool
tagging string
opType operationType
bSyncCommand bool
Expand Down Expand Up @@ -1314,6 +1315,7 @@ var copyCommand = CopyCommand{
OptionRegion,
OptionCloudBoxID,
OptionForcePathStyle,
OptionOnlyShowErrors,
OptionStartTime,
OptionEndTime,
},
Expand Down Expand Up @@ -1361,6 +1363,7 @@ func (cc *CopyCommand) RunCommand() error {
cc.cpOption.onlyCurrentDir, _ = GetBool(OptionOnlyCurrentDir, cc.command.options)
cc.cpOption.disableDirObject, _ = GetBool(OptionDisableDirObject, cc.command.options)
cc.cpOption.disableAllSymlink, _ = GetBool(OptionDisableAllSymlink, cc.command.options)
cc.cpOption.onlyShowErrors, _ = GetBool(OptionOnlyShowErrors, cc.command.options)

if cc.cpOption.enableSymlinkDir && cc.cpOption.disableAllSymlink {
return fmt.Errorf("--enable-symlink-dir and --disable-all-symlink can't be both exist")
Expand Down Expand Up @@ -1522,7 +1525,9 @@ func (cc *CopyCommand) RunCommand() error {
endT := time.Now().UnixNano() / 1000 / 1000
if endT-startT > 0 {
averSpeed := (cc.monitor.transferSize / (endT - startT)) * 1000
fmt.Printf("\naverage speed %d(byte/s)\n", averSpeed)
if !cc.cpOption.onlyShowErrors {
fmt.Printf("\naverage speed %d(byte/s)\n", averSpeed)
}
LogInfo("average speed %d(byte/s)\n", averSpeed)
}

Expand Down Expand Up @@ -1620,7 +1625,9 @@ func (cc *CopyCommand) checkCopyOptions(opType operationType) error {
func (cc *CopyCommand) progressBar() {
// fetch all reveal
for signal := range chProgressSignal {
fmt.Printf(cc.monitor.progressBar(signal.finish, signal.exitStat))
if !cc.cpOption.onlyShowErrors {
fmt.Printf(cc.monitor.progressBar(signal.finish, signal.exitStat))
}
}
}

Expand Down Expand Up @@ -1678,14 +1685,18 @@ func (cc *CopyCommand) uploadFiles(srcURLList []StorageURLer, destURL CloudURL)
} else {
if !cc.cpOption.ctnu {
cc.closeProgress()
fmt.Printf(cc.monitor.progressBar(true, errExit))
if !cc.cpOption.onlyShowErrors {
fmt.Printf(cc.monitor.progressBar(true, errExit))
}
return err
}
}
}
}
cc.closeProgress()
fmt.Printf(cc.monitor.progressBar(true, normalExit))
if !cc.cpOption.onlyShowErrors {
fmt.Printf(cc.monitor.progressBar(true, normalExit))
}
return listError
}

Expand Down Expand Up @@ -2414,7 +2425,9 @@ func (cc *CopyCommand) downloadFiles(srcURL CloudURL, destURL FileURL) error {

func (cc *CopyCommand) formatResultPrompt(err error) error {
cc.closeProgress()
fmt.Printf(cc.monitor.progressBar(true, normalExit))
if !cc.cpOption.onlyShowErrors {
fmt.Printf(cc.monitor.progressBar(true, normalExit))
}
if err != nil && cc.cpOption.ctnu {
return nil
}
Expand Down Expand Up @@ -2608,8 +2621,10 @@ func (cc *CopyCommand) ossDownloadFileRetry(bucket *oss.Bucket, objectName, file
for i := 1; ; i++ {
if i > 1 {
time.Sleep(time.Duration(3) * time.Second)
if int64(i) >= retryTimes {
fmt.Printf("\nretry count:%d:get object to file:%s.\n", i-1, fileName)
if !cc.cpOption.onlyShowErrors {
if int64(i) >= retryTimes {
fmt.Printf("\nretry count:%d:get object to file:%s.\n", i-1, fileName)
}
}
}

Expand Down Expand Up @@ -2638,8 +2653,10 @@ func (cc *CopyCommand) ossResumeDownloadRetry(bucket *oss.Bucket, objectName str
for i := 1; ; i++ {
if i > 1 {
time.Sleep(time.Duration(3) * time.Second)
if int64(i) >= retryTimes {
fmt.Printf("\nretry count:%d:mulitpart download file:%s.\n", i-1, objectName)
if !cc.cpOption.onlyShowErrors {
if int64(i) >= retryTimes {
fmt.Printf("\nretry count:%d:mulitpart download file:%s.\n", i-1, objectName)
}
}
}

Expand Down Expand Up @@ -2896,7 +2913,9 @@ func (cc *CopyCommand) waitRoutinueComplete(chError, chListError <-chan error, o
ferr = err
if !cc.cpOption.ctnu {
cc.closeProgress()
fmt.Printf(cc.monitor.progressBar(true, errExit))
if !cc.cpOption.onlyShowErrors {
fmt.Printf(cc.monitor.progressBar(true, errExit))
}
return err
}
}
Expand Down Expand Up @@ -3069,8 +3088,10 @@ func (cc *CopyCommand) ossCopyObjectRetry(bucket *oss.Bucket, objectName, destBu
for i := 1; ; i++ {
if i > 1 {
time.Sleep(time.Duration(3) * time.Second)
if int64(i) >= retryTimes {
fmt.Printf("\nretry count:%d,copy object:%s.\n", i-1, objectName)
if !cc.cpOption.onlyShowErrors {
if int64(i) >= retryTimes {
fmt.Printf("\nretry count:%d,copy object:%s.\n", i-1, objectName)
}
}
}
_, err := bucket.CopyObjectTo(destBucketName, destObjectName, objectName, options...)
Expand All @@ -3096,9 +3117,12 @@ func (cc *CopyCommand) ossResumeCopyRetry(bucketName, objectName, destBucketName
for i := 1; ; i++ {
if i > 1 {
time.Sleep(time.Duration(3) * time.Second)
if int64(i) >= retryTimes {
fmt.Printf("\nretry count:%d, resume copy object:%s.\n", i-1, objectName)
if !cc.cpOption.onlyShowErrors {
if int64(i) >= retryTimes {
fmt.Printf("\nretry count:%d, resume copy object:%s.\n", i-1, objectName)
}
}

}

err := bucket.CopyFile(bucketName, objectName, destObjectName, partSize, options...)
Expand Down
Loading