Skip to content

Commit

Permalink
Fixed panic when running tests on Windows network drive
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kozlovic committed Aug 31, 2017
1 parent 9fe9509 commit a7ef59f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions server/clustering_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
2 changes: 1 addition & 1 deletion server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down

0 comments on commit a7ef59f

Please sign in to comment.