filter: reload filter when the options are set via the rc - fixes #3018

This commit is contained in:
Nick Craig-Wood 2019-03-06 12:37:15 +00:00
parent cccadfa7ae
commit 58d9a3e1b5
2 changed files with 8 additions and 3 deletions

View File

@ -341,8 +341,7 @@ func initConfig() {
configflags.SetFlags()
// Load filters
var err error
filter.Active, err = filter.NewFilter(&filterflags.Opt)
err := filterflags.Reload()
if err != nil {
log.Fatalf("Failed to load filters: %v", err)
}

View File

@ -13,9 +13,15 @@ var (
Opt = filter.DefaultOpt
)
// Reload the filters from the flags
func Reload() (err error) {
filter.Active, err = filter.NewFilter(&Opt)
return err
}
// AddFlags adds the non filing system specific flags to the command
func AddFlags(flagSet *pflag.FlagSet) {
rc.AddOption("filter", &Opt)
rc.AddOptionReload("filter", &Opt, Reload)
flags.BoolVarP(flagSet, &Opt.DeleteExcluded, "delete-excluded", "", false, "Delete files on dest excluded from sync")
flags.StringArrayVarP(flagSet, &Opt.FilterRule, "filter", "f", nil, "Add a file-filtering rule")
flags.StringArrayVarP(flagSet, &Opt.FilterFrom, "filter-from", "", nil, "Read filtering patterns from a file")