2
2
mirror of https://github.com/octoleo/restic.git synced 2024-10-31 19:02:32 +00:00
This commit is contained in:
Tobias Klein 2017-09-09 18:19:19 +02:00
parent 8f9ef4402b
commit ed30bd7b76

View File

@ -6,8 +6,8 @@ import (
"sort"
"strings"
"github.com/restic/restic/internal/restic"
"github.com/restic/restic/internal/errors"
"github.com/restic/restic/internal/restic"
"github.com/spf13/cobra"
)
@ -98,15 +98,19 @@ func runForget(opts ForgetOptions, gopts GlobalOptions, args []string) error {
var GroupByPath bool
var GroupOptionList []string
GroupOptionList = strings.Split( opts.GroupBy, "," )
GroupOptionList = strings.Split(opts.GroupBy, ",")
for _, option := range GroupOptionList {
switch( option ) {
case "host": GroupByHost = true
case "paths": GroupByPath = true
case "tags": GroupByTag = true
switch option {
case "host":
GroupByHost = true
case "paths":
GroupByPath = true
case "tags":
GroupByTag = true
case "":
default: return errors.Fatal( "unknown grouping option: '" + option + "'" )
default:
return errors.Fatal("unknown grouping option: '" + option + "'")
}
}
@ -180,21 +184,21 @@ func runForget(opts ForgetOptions, gopts GlobalOptions, args []string) error {
}
// Info
Verbosef( "snapshots" )
Verbosef("snapshots")
var infoStrings []string
if GroupByTag {
infoStrings = append( infoStrings, "tags [" + strings.Join( key.Tags, ", " ) + "]" )
infoStrings = append(infoStrings, "tags ["+strings.Join(key.Tags, ", ")+"]")
}
if GroupByHost {
infoStrings = append( infoStrings, "host [" + key.Hostname + "]" )
infoStrings = append(infoStrings, "host ["+key.Hostname+"]")
}
if GroupByPath {
infoStrings = append( infoStrings, "paths [" + strings.Join( key.Paths, ", " ) + "]" )
infoStrings = append(infoStrings, "paths ["+strings.Join(key.Paths, ", ")+"]")
}
if infoStrings != nil {
Verbosef( " for (" + strings.Join( infoStrings, ", " ) + ")" )
Verbosef(" for (" + strings.Join(infoStrings, ", ") + ")")
}
Verbosef( ":\n\n" )
Verbosef(":\n\n")
keep, remove := restic.ApplyPolicy(snapshotGroup, policy)