From 1a46f5578652959eef6b953da4aaac77e072288e Mon Sep 17 00:00:00 2001 From: chrislu Date: Fri, 31 Oct 2025 17:07:08 -0700 Subject: [PATCH] If both -readOnly and -writeOnly are specified, the current logic silently allows it with -writeOnly taking precedence. This is confusing and could lead to unexpected behavior. --- weed/command/benchmark.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/weed/command/benchmark.go b/weed/command/benchmark.go index 4de615ea5..660e31921 100644 --- a/weed/command/benchmark.go +++ b/weed/command/benchmark.go @@ -137,15 +137,16 @@ func runBenchmark(cmd *Command, args []string) bool { // Default: both write and read // -readOnly: only read // -writeOnly: only write + if *b.readOnly && *b.writeOnly { + fmt.Fprintln(os.Stderr, "Error: -readOnly and -writeOnly are mutually exclusive.") + return false + } + doWrite := true doRead := true - if *b.readOnly { doWrite = false - doRead = true - } - if *b.writeOnly { - doWrite = true + } else if *b.writeOnly { doRead = false }