forked from TrueCloudLab/restic
mount: fix exit code on cancellation
This commit is contained in:
parent
6f2a4dea21
commit
910927670f
2 changed files with 6 additions and 1 deletions
|
@ -190,7 +190,7 @@ func runMount(ctx context.Context, opts MountOptions, gopts GlobalOptions, args
|
||||||
Warnf("unable to umount (maybe already umounted or still in use?): %v\n", err)
|
Warnf("unable to umount (maybe already umounted or still in use?): %v\n", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return ErrOK
|
||||||
case <-done:
|
case <-done:
|
||||||
// clean shutdown, nothing to do
|
// clean shutdown, nothing to do
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,8 @@ func init() {
|
||||||
_, _ = maxprocs.Set()
|
_, _ = maxprocs.Set()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var ErrOK = errors.New("ok")
|
||||||
|
|
||||||
// cmdRoot is the base command when no other command has been specified.
|
// cmdRoot is the base command when no other command has been specified.
|
||||||
var cmdRoot = &cobra.Command{
|
var cmdRoot = &cobra.Command{
|
||||||
Use: "restic",
|
Use: "restic",
|
||||||
|
@ -125,6 +127,9 @@ func main() {
|
||||||
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
err = ctx.Err()
|
err = ctx.Err()
|
||||||
|
} else if err == ErrOK {
|
||||||
|
// ErrOK overwrites context cancelation errors
|
||||||
|
err = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
|
|
Loading…
Add table
Reference in a new issue