mirror of
https://github.com/rclone/rclone
synced 2024-11-25 02:47:14 +01:00
Make sure high level retries show with -q - fixes #648
Also update the exit code documentation describing that.
This commit is contained in:
parent
bbf819e2d1
commit
4001e21624
11
cmd/cmd.go
11
cmd/cmd.go
@ -161,20 +161,23 @@ func Run(Retry bool, cmd *cobra.Command, f func() error) {
|
|||||||
for try := 1; try <= *retries; try++ {
|
for try := 1; try <= *retries; try++ {
|
||||||
err = f()
|
err = f()
|
||||||
if !Retry || (err == nil && !fs.Stats.Errored()) {
|
if !Retry || (err == nil && !fs.Stats.Errored()) {
|
||||||
|
if try > 1 {
|
||||||
|
fs.ErrorLog(nil, "Attempt %d/%d succeeded", try, *retries)
|
||||||
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if fs.IsFatalError(err) {
|
if fs.IsFatalError(err) {
|
||||||
fs.Log(nil, "Fatal error received - not attempting retries")
|
fs.ErrorLog(nil, "Fatal error received - not attempting retries")
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if fs.IsNoRetryError(err) {
|
if fs.IsNoRetryError(err) {
|
||||||
fs.Log(nil, "Can't retry this error - not attempting retries")
|
fs.ErrorLog(nil, "Can't retry this error - not attempting retries")
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fs.Log(nil, "Attempt %d/%d failed with %d errors and: %v", try, *retries, fs.Stats.GetErrors(), err)
|
fs.ErrorLog(nil, "Attempt %d/%d failed with %d errors and: %v", try, *retries, fs.Stats.GetErrors(), err)
|
||||||
} else {
|
} else {
|
||||||
fs.Log(nil, "Attempt %d/%d failed with %d errors", try, *retries, fs.Stats.GetErrors())
|
fs.ErrorLog(nil, "Attempt %d/%d failed with %d errors", try, *retries, fs.Stats.GetErrors())
|
||||||
}
|
}
|
||||||
if try < *retries {
|
if try < *retries {
|
||||||
fs.Stats.ResetErrors()
|
fs.Stats.ResetErrors()
|
||||||
|
@ -629,7 +629,18 @@ If you use the `--log-file=FILE` option, rclone will redirect `Error`,
|
|||||||
Exit Code
|
Exit Code
|
||||||
---------
|
---------
|
||||||
|
|
||||||
If any errors occurred during the command, rclone will set a non zero
|
If any errors occurred during the command, rclone with an exit code of
|
||||||
exit code. This allows scripts to detect when rclone operations have
|
`1`. This allows scripts to detect when rclone operations have failed.
|
||||||
failed.
|
|
||||||
|
|
||||||
|
During the startup phase rclone will exit immediately if an error is
|
||||||
|
detected in the configuration. There will always be a log message
|
||||||
|
immediately before exiting.
|
||||||
|
|
||||||
|
When rclone is running it will accumulate errors as it goes along, and
|
||||||
|
only exit with an non-zero exit code if (after retries) there were no
|
||||||
|
transfers with errors remaining. For every error counted there will
|
||||||
|
be a high priority log message (visibile with `-q`) showing the
|
||||||
|
message and which file caused the problem. A high priority message is
|
||||||
|
also shown when starting a retry so the user can see that any previous
|
||||||
|
error messages may not be valid after the retry. If rclone has done a
|
||||||
|
retry it will log a high priority message if the retry was successful.
|
||||||
|
@ -4,8 +4,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"log"
|
||||||
"os"
|
|
||||||
|
|
||||||
"github.com/ncw/rclone/cmd"
|
"github.com/ncw/rclone/cmd"
|
||||||
_ "github.com/ncw/rclone/cmd/all" // import all commands
|
_ "github.com/ncw/rclone/cmd/all" // import all commands
|
||||||
@ -14,8 +13,6 @@ import (
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
if err := cmd.Root.Execute(); err != nil {
|
if err := cmd.Root.Execute(); err != nil {
|
||||||
fmt.Println(err)
|
log.Fatalf("Fatal error: %v", err)
|
||||||
os.Exit(-1)
|
|
||||||
}
|
}
|
||||||
os.Exit(0)
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user