From 58d9a3e1b5e68184f1f1761ed690e67f821fb506 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Wed, 6 Mar 2019 12:37:15 +0000 Subject: [PATCH] filter: reload filter when the options are set via the rc - fixes #3018 --- cmd/cmd.go | 3 +-- fs/filter/filterflags/filterflags.go | 8 +++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/cmd/cmd.go b/cmd/cmd.go index c86c55d2b..b174f3fa4 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -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) } diff --git a/fs/filter/filterflags/filterflags.go b/fs/filter/filterflags/filterflags.go index 22c4ad271..26b0aa5be 100644 --- a/fs/filter/filterflags/filterflags.go +++ b/fs/filter/filterflags/filterflags.go @@ -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")