mirror of
https://github.com/rclone/rclone.git
synced 2024-11-22 16:34:30 +01:00
fs: fix --dump filters not always appearing
Before this fix, we initialised the options blocks in a random order. This meant that there was a 50/50 chance whether --dump filters would show the filters or not as it was depending on the "main" block having being read first to set the Dump flags. This initialises the options blocks in a defined order which is alphabetically but with main first which fixes the problem.
This commit is contained in:
parent
c0bfedf99c
commit
d6a5fc6ffa
@ -531,7 +531,22 @@ func (oi *OptionsInfo) load() error {
|
|||||||
// their values read from the options, environment variables and
|
// their values read from the options, environment variables and
|
||||||
// command line parameters.
|
// command line parameters.
|
||||||
func GlobalOptionsInit() error {
|
func GlobalOptionsInit() error {
|
||||||
for _, opt := range OptionsRegistry {
|
var keys []string
|
||||||
|
for key := range OptionsRegistry {
|
||||||
|
keys = append(keys, key)
|
||||||
|
}
|
||||||
|
sort.Slice(keys, func(i, j int) bool {
|
||||||
|
// Sort alphabetically, but with "main" first
|
||||||
|
if keys[i] == "main" {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if keys[j] == "main" {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return keys[i] < keys[j]
|
||||||
|
})
|
||||||
|
for _, key := range keys {
|
||||||
|
opt := OptionsRegistry[key]
|
||||||
err := opt.load()
|
err := opt.load()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
Loading…
Reference in New Issue
Block a user