From c05c66814891c3cccef394162e428444b53394e4 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Sat, 25 Jul 2026 07:25:26 +0200 Subject: [PATCH] fix: process --FollowExternalSymlinks --- cmd/cmd_test.go | 26 ++++++++++++++++++++++++++ cmd/config.go | 2 ++ 2 files changed, 28 insertions(+) diff --git a/cmd/cmd_test.go b/cmd/cmd_test.go index e4b45c47..91a9c632 100644 --- a/cmd/cmd_test.go +++ b/cmd/cmd_test.go @@ -5,6 +5,10 @@ import ( "github.com/samber/lo" "github.com/spf13/cobra" + "github.com/spf13/pflag" + + "github.com/filebrowser/filebrowser/v2/auth" + "github.com/filebrowser/filebrowser/v2/settings" ) // TestEnvCollisions ensures that there are no collisions in the produced environment @@ -33,3 +37,25 @@ func testEnvCollisions(t *testing.T, cmd *cobra.Command) { t.Errorf("Found duplicate environment variable keys for command %q: %v", cmd.Name(), duplicates) } } + +// TestGetSettingsFollowExternalSymlinks ensures that the followExternalSymlinks +// flag is persisted to the server config when set via "config set". +func TestGetSettingsFollowExternalSymlinks(t *testing.T) { + flags := pflag.NewFlagSet("test", pflag.ContinueOnError) + addConfigFlags(flags) + + if err := flags.Parse([]string{"--followExternalSymlinks"}); err != nil { + t.Fatal(err) + } + + set := &settings.Settings{AuthMethod: auth.MethodJSONAuth} + ser := &settings.Server{} + + if _, err := getSettings(flags, set, ser, &auth.JSONAuth{}, false); err != nil { + t.Fatal(err) + } + + if !ser.FollowExternalSymlinks { + t.Error("expected FollowExternalSymlinks to be persisted as true") + } +} diff --git a/cmd/config.go b/cmd/config.go index cf923eac..b292f01d 100644 --- a/cmd/config.go +++ b/cmd/config.go @@ -314,6 +314,8 @@ func getSettings(flags *pflag.FlagSet, set *settings.Settings, ser *settings.Ser case "disableImageResolutionCalc": ser.ImageResolutionCal, err = flags.GetBool(flag.Name) ser.ImageResolutionCal = !ser.ImageResolutionCal + case "followExternalSymlinks": + ser.FollowExternalSymlinks, err = flags.GetBool(flag.Name) // Settings flags from [addConfigFlags] case "signup":