Skip to content

Commit

Permalink
[FIXED] Command line -file_slice_max_bytes 0 was not working
Browse files Browse the repository at this point in the history
It was impossible to set the file slice max bytes to 0. The default
64MB value would be used. Note that setting it in the configuration
file would work, only the command line would not.

Signed-off-by: Ivan Kozlovic <[email protected]>
  • Loading branch information
kozlovic committed Oct 26, 2020
1 parent 7ce6644 commit 85334be
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions server/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,8 @@ func ConfigureOptions(fs *flag.FlagSet, args []string, printVersion, printHelp,
var i64 int64
i64, flagErr = getBytes(f)
sopts.FileStoreOpts.ReadBufferSize = int(i64)
case "file_slice_max_bytes":
sopts.FileStoreOpts.SliceMaxBytes, flagErr = getBytes(f)
}
})
if flagErr != nil {
Expand Down
18 changes: 18 additions & 0 deletions server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1607,3 +1607,21 @@ SUAKYRHVIOREXV7EUZTBHUHL7NUMHPMAS7QMDU3GTIUWEI5LDNOXD43IZY
t.Fatal("Expected failure to start")
}
}

func TestFileSliceMaxBytesCmdLine(t *testing.T) {
fs := flag.NewFlagSet("test", flag.ContinueOnError)
noPrint := func() {}
sopts, nopts, err := ConfigureOptions(fs, []string{"-store", "file", "-dir", defaultDataStore, "-file_slice_max_bytes", "0"}, noPrint, noPrint, noPrint)
if err != nil {
t.Fatalf("Error on configure: %v", err)
}
s := runServerWithOpts(t, sopts, nopts)
defer s.Shutdown()

s.mu.Lock()
smb := s.opts.FileStoreOpts.SliceMaxBytes
s.mu.Unlock()
if smb != 0 {
t.Fatalf("Expected value to be 0, got %v", smb)
}
}

0 comments on commit 85334be

Please sign in to comment.