2
2
mirror of https://github.com/octoleo/restic.git synced 2024-12-22 10:58:55 +00:00

Represent -1 as "all" in ExpirePolicy's Stringer

This commit is contained in:
Torben Giesselmann 2023-03-15 15:07:51 -07:00
parent 1a584cb16e
commit 5069c9edd9

View File

@ -31,23 +31,22 @@ func (e ExpirePolicy) String() (s string) {
var keeps []string var keeps []string
var keepw []string var keepw []string
if e.Last > 0 { for _, opt := range []struct {
keeps = append(keeps, fmt.Sprintf("%d latest", e.Last)) count int
} descr string
if e.Hourly > 0 { }{
keeps = append(keeps, fmt.Sprintf("%d hourly", e.Hourly)) {e.Last, "latest"},
} {e.Hourly, "hourly"},
if e.Daily > 0 { {e.Daily, "daily"},
keeps = append(keeps, fmt.Sprintf("%d daily", e.Daily)) {e.Weekly, "weekly"},
} {e.Monthly, "monthly"},
if e.Weekly > 0 { {e.Yearly, "yearly"},
keeps = append(keeps, fmt.Sprintf("%d weekly", e.Weekly)) } {
} if opt.count > 0 {
if e.Monthly > 0 { keeps = append(keeps, fmt.Sprintf("%d %s", opt.count, opt.descr))
keeps = append(keeps, fmt.Sprintf("%d monthly", e.Monthly)) } else if opt.count == -1 {
} keeps = append(keeps, fmt.Sprintf("all %s", opt.descr))
if e.Yearly > 0 { }
keeps = append(keeps, fmt.Sprintf("%d yearly", e.Yearly))
} }
if !e.WithinHourly.Zero() { if !e.WithinHourly.Zero() {