bisync: change exit code from 2 to 7 for critically aborted run

This commit is contained in:
albertony 2024-01-27 20:44:12 +01:00
parent a849fd59f0
commit 3dec664a19
3 changed files with 8 additions and 4 deletions

View File

@ -20,6 +20,7 @@ import (
"github.com/rclone/rclone/fs/config" "github.com/rclone/rclone/fs/config"
"github.com/rclone/rclone/fs/config/flags" "github.com/rclone/rclone/fs/config/flags"
"github.com/rclone/rclone/fs/filter" "github.com/rclone/rclone/fs/filter"
"github.com/rclone/rclone/fs/fserrors"
"github.com/rclone/rclone/fs/hash" "github.com/rclone/rclone/fs/hash"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@ -193,7 +194,7 @@ var commandDefinition = &cobra.Command{
cmd.Run(false, true, command, func() error { cmd.Run(false, true, command, func() error {
err := Bisync(ctx, fs1, fs2, &opt) err := Bisync(ctx, fs1, fs2, &opt)
if err == ErrBisyncAborted { if err == ErrBisyncAborted {
os.Exit(2) return fserrors.FatalError(err)
} }
return err return err
}) })

View File

@ -23,7 +23,7 @@ import (
"github.com/rclone/rclone/lib/terminal" "github.com/rclone/rclone/lib/terminal"
) )
// ErrBisyncAborted signals that bisync is aborted and forces exit code 2 // ErrBisyncAborted signals that bisync is aborted and forces non-zero exit code
var ErrBisyncAborted = errors.New("bisync aborted") var ErrBisyncAborted = errors.New("bisync aborted")
// bisyncRun keeps bisync runtime state // bisyncRun keeps bisync runtime state

View File

@ -968,12 +968,15 @@ that while concurrent bisync runs are allowed, _be very cautious_
that there is no overlap in the trees being synched between concurrent runs, that there is no overlap in the trees being synched between concurrent runs,
lest there be replicated files, deleted files and general mayhem. lest there be replicated files, deleted files and general mayhem.
### Return codes ### Exit codes
`rclone bisync` returns the following codes to calling program: `rclone bisync` returns the following codes to calling program:
- `0` on a successful run, - `0` on a successful run,
- `1` for a non-critical failing run (a rerun may be successful), - `1` for a non-critical failing run (a rerun may be successful),
- `2` for a critically aborted run (requires a `--resync` to recover). - `2` on syntax or usage error,
- `7` for a critically aborted run (requires a `--resync` to recover).
See also the section about [exit codes](/docs/#exit-code) in main docs.
### Graceful Shutdown ### Graceful Shutdown