From c1f66ea4ebcf579697e9c524b400d613583039f6 Mon Sep 17 00:00:00 2001 From: Sergey Berezansky Date: Sun, 7 May 2023 16:18:25 +0300 Subject: [PATCH] fix: better fix for mount options Merge with mutually excluding options --- pkg/wekafs/mountoptions.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/pkg/wekafs/mountoptions.go b/pkg/wekafs/mountoptions.go index 9ccd5d937..341300854 100644 --- a/pkg/wekafs/mountoptions.go +++ b/pkg/wekafs/mountoptions.go @@ -53,12 +53,18 @@ type MountOptions struct { func (opts MountOptions) Merge(other MountOptions, exclusives []mutuallyExclusiveMountOptionSet) { for _, otherOpt := range other.customOptions { opts.customOptions[otherOpt.option] = otherOpt - for _, exclusiveOpts := range exclusives { - for _, opt := range exclusiveOpts { + // iterate on all sets of mutually exclusive options + for _, exclusiveOptsSet := range exclusives { + // iterate on all options in one exclusive set + for _, opt := range exclusiveOptsSet { if otherOpt.option == opt { - for _, optionToDrop := range exclusiveOpts { - delete(opts.customOptions, optionToDrop) + // if the option exists in exclusiveOptsSet, we need to drop all its alternatives from original options + for _, optionToDrop := range exclusiveOptsSet { + if optionToDrop != opt { + delete(opts.customOptions, optionToDrop) + } } + break // stop iterating on the rest } } }