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")