From a7ef59f687f4d3f7f90f5828c629faa4e5a954c5 Mon Sep 17 00:00:00 2001 From: Ivan Kozlovic Date: Wed, 30 Aug 2017 19:34:23 -0600 Subject: [PATCH] Fixed panic when running tests on Windows network drive The raft log was located in current directory, which when running on a network drive on Windows was crashing without any indication that this was the caused. Changing call to ioutil.TempDir() to use "" instead of ".", which on Windows will then create the files in the Windows temp directory which by default is in C:\. This solves the panic. --- server/clustering_test.go | 3 +-- server/server.go | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/server/clustering_test.go b/server/clustering_test.go index 25d5ad03..4799a98d 100644 --- a/server/clustering_test.go +++ b/server/clustering_test.go @@ -17,14 +17,13 @@ import ( natsdTest "github.com/nats-io/gnatsd/test" "github.com/nats-io/go-nats-streaming" "github.com/nats-io/go-nats-streaming/pb" - "github.com/nats-io/nats-streaming-server/stores" ) var defaultRaftLog string func init() { - tmpDir, err := ioutil.TempDir(".", "raft_logs_") + tmpDir, err := ioutil.TempDir("", "raft_logs_") if err != nil { panic("Could not create tmp dir") } diff --git a/server/server.go b/server/server.go index 966af20a..b8399d13 100644 --- a/server/server.go +++ b/server/server.go @@ -280,7 +280,7 @@ func (cs *channelStore) create(s *StanServer, name string, sc *stores.Channel) ( func assignChannelRaft(s *StanServer, c *channel) error { path := filepath.Join(s.opts.RaftLogPath, c.name) if _, err := os.Stat(path); os.IsNotExist(err) { - if err := os.MkdirAll(path, os.ModePerm); err != nil { + if err := os.MkdirAll(path, os.ModeDir+os.ModePerm); err != nil { return err } }