fix: crash in cp when cpURLs return error (#3035)
This commit is contained in:
+22
-4
@@ -338,6 +338,7 @@ func doCopySession(cli *cli.Context, session *sessionV8, encKeyDB map[string][]p
|
||||
close(cpURLsCh)
|
||||
break
|
||||
}
|
||||
|
||||
var cpURLs URLs
|
||||
if e := json.Unmarshal([]byte(urlScanner.Text()), &cpURLs); e != nil {
|
||||
errorIf(probe.NewError(e), "Unable to unmarshal %s", urlScanner.Text())
|
||||
@@ -359,10 +360,27 @@ func doCopySession(cli *cli.Context, session *sessionV8, encKeyDB map[string][]p
|
||||
|
||||
go func() {
|
||||
totalBytes := int64(0)
|
||||
for cpURLs := range prepareCopyURLs(sourceURLs, targetURL, isRecursive, encKeyDB, olderThan, newerThan) {
|
||||
totalBytes += cpURLs.SourceContent.Size
|
||||
pg.SetTotal(totalBytes)
|
||||
|
||||
for cpURLs := range prepareCopyURLs(sourceURLs, targetURL, isRecursive,
|
||||
encKeyDB, olderThan, newerThan) {
|
||||
if cpURLs.Error != nil {
|
||||
// Print in new line and adjust to top so that we
|
||||
// don't print over the ongoing scan bar
|
||||
if !globalQuiet && !globalJSON {
|
||||
console.Eraseline()
|
||||
}
|
||||
if strings.Contains(cpURLs.Error.ToGoError().Error(),
|
||||
" is a folder.") {
|
||||
errorIf(cpURLs.Error.Trace(),
|
||||
"Folder cannot be copied. Please use `...` suffix.")
|
||||
} else {
|
||||
errorIf(cpURLs.Error.Trace(),
|
||||
"Unable to start copying.")
|
||||
}
|
||||
break
|
||||
} else {
|
||||
totalBytes += cpURLs.SourceContent.Size
|
||||
pg.SetTotal(totalBytes)
|
||||
}
|
||||
cpURLsCh <- cpURLs
|
||||
}
|
||||
close(cpURLsCh)
|
||||
|
||||
@@ -15,7 +15,7 @@ require (
|
||||
github.com/mattn/go-runewidth v0.0.5 // indirect
|
||||
github.com/minio/cli v1.22.0
|
||||
github.com/minio/minio v0.0.0-20191231040613-0b7bd024fb30
|
||||
github.com/minio/minio-go/v6 v6.0.45-0.20191213193129-a5786a9c2a5b
|
||||
github.com/minio/minio-go/v6 v6.0.45-0.20200107003430-a505b7da2279
|
||||
github.com/minio/sha256-simd v0.1.1
|
||||
github.com/mitchellh/go-homedir v1.1.0
|
||||
github.com/pkg/profile v1.3.0
|
||||
|
||||
@@ -261,8 +261,8 @@ github.com/minio/lsync v1.0.1/go.mod h1:tCFzfo0dlvdGl70IT4IAK/5Wtgb0/BrTmo/jE8pA
|
||||
github.com/minio/minio v0.0.0-20191231040613-0b7bd024fb30 h1:s6Bt9fdUAbQ1UFssnNgB79o6xTrTHVEk3Q96QF3qAw8=
|
||||
github.com/minio/minio v0.0.0-20191231040613-0b7bd024fb30/go.mod h1:4Aa1o4tNqOR8ZAR80H2UCTcIi7w6H1QqHywiKXcYimM=
|
||||
github.com/minio/minio-go/v6 v6.0.44/go.mod h1:qD0lajrGW49lKZLtXKtCB4X/qkMf0a5tBvN2PaZg7Gg=
|
||||
github.com/minio/minio-go/v6 v6.0.45-0.20191213193129-a5786a9c2a5b h1:mzW6HUPIw2tUQsUx7x4z4RPWABWFKnI6j47DIZNl53A=
|
||||
github.com/minio/minio-go/v6 v6.0.45-0.20191213193129-a5786a9c2a5b/go.mod h1:qD0lajrGW49lKZLtXKtCB4X/qkMf0a5tBvN2PaZg7Gg=
|
||||
github.com/minio/minio-go/v6 v6.0.45-0.20200107003430-a505b7da2279 h1:QJEZTaHQKwJbImgZKN12fwk41Gh75xZk+9Y4vGFRSf0=
|
||||
github.com/minio/minio-go/v6 v6.0.45-0.20200107003430-a505b7da2279/go.mod h1:qD0lajrGW49lKZLtXKtCB4X/qkMf0a5tBvN2PaZg7Gg=
|
||||
github.com/minio/parquet-go v0.0.0-20191231003236-20b3c07bcd2c h1:PXr/55MEoFh0G6NeV0plWrdpTDr5xaDTxP3SpavSdGc=
|
||||
github.com/minio/parquet-go v0.0.0-20191231003236-20b3c07bcd2c/go.mod h1:sl82d+TnCE7qeaNJazHdNoG9Gpyl9SZYfleDAQWrsls=
|
||||
github.com/minio/sha256-simd v0.1.1 h1:5QHSlgo3nt5yKOJrC7W8w7X+NFl8cMPZm96iu8kKUJU=
|
||||
|
||||
Reference in New Issue
Block a user