forked from TrueCloudLab/restic
forget: Allow neg. values in "--keep-within*" opts
This commit is contained in:
parent
ba183c44c3
commit
667536cea4
2 changed files with 0 additions and 35 deletions
|
@ -107,16 +107,6 @@ func verifyForgetOptions(opts *ForgetOptions) error {
|
||||||
negValFound = true
|
negValFound = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if !negValFound {
|
|
||||||
for _, d := range [6]restic.Duration{opts.Within, opts.WithinHourly, opts.WithinDaily,
|
|
||||||
opts.WithinMonthly, opts.WithinWeekly, opts.WithinYearly} {
|
|
||||||
if d.Hours < -1 || d.Days < -1 || d.Months < -1 || d.Years < -1 {
|
|
||||||
negValFound = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if negValFound {
|
if negValFound {
|
||||||
return errors.Fatal("negative values other than -1 are not allowed for --keep-* options")
|
return errors.Fatal("negative values other than -1 are not allowed for --keep-* options")
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/restic/restic/internal/restic"
|
|
||||||
rtest "github.com/restic/restic/internal/test"
|
rtest "github.com/restic/restic/internal/test"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -16,30 +15,6 @@ func TestPreventNegativeForgetOptionValues(t *testing.T) {
|
||||||
{Weekly: -2},
|
{Weekly: -2},
|
||||||
{Monthly: -2},
|
{Monthly: -2},
|
||||||
{Yearly: -2},
|
{Yearly: -2},
|
||||||
{Within: restic.Duration{Hours: -2}},
|
|
||||||
{Within: restic.Duration{Days: -2}},
|
|
||||||
{Within: restic.Duration{Months: -2}},
|
|
||||||
{Within: restic.Duration{Years: -2}},
|
|
||||||
{WithinHourly: restic.Duration{Hours: -2}},
|
|
||||||
{WithinHourly: restic.Duration{Days: -2}},
|
|
||||||
{WithinHourly: restic.Duration{Months: -2}},
|
|
||||||
{WithinHourly: restic.Duration{Years: -2}},
|
|
||||||
{WithinDaily: restic.Duration{Hours: -2}},
|
|
||||||
{WithinDaily: restic.Duration{Days: -2}},
|
|
||||||
{WithinDaily: restic.Duration{Months: -2}},
|
|
||||||
{WithinDaily: restic.Duration{Years: -2}},
|
|
||||||
{WithinWeekly: restic.Duration{Hours: -2}},
|
|
||||||
{WithinWeekly: restic.Duration{Days: -2}},
|
|
||||||
{WithinWeekly: restic.Duration{Months: -2}},
|
|
||||||
{WithinWeekly: restic.Duration{Years: -2}},
|
|
||||||
{WithinMonthly: restic.Duration{Hours: -2}},
|
|
||||||
{WithinMonthly: restic.Duration{Days: -2}},
|
|
||||||
{WithinMonthly: restic.Duration{Months: -2}},
|
|
||||||
{WithinMonthly: restic.Duration{Years: -2}},
|
|
||||||
{WithinYearly: restic.Duration{Hours: -2}},
|
|
||||||
{WithinYearly: restic.Duration{Days: -2}},
|
|
||||||
{WithinYearly: restic.Duration{Months: -2}},
|
|
||||||
{WithinYearly: restic.Duration{Years: -2}},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, opts := range invalidForgetOpts {
|
for _, opts := range invalidForgetOpts {
|
||||||
|
|
Loading…
Reference in a new issue