diff --git a/snap/snapshotter.go b/snap/snapshotter.go index 1f3ce6fa6..999aab719 100644 --- a/snap/snapshotter.go +++ b/snap/snapshotter.go @@ -31,7 +31,7 @@ func New(dir string) *Snapshotter { } func (s *Snapshotter) Save(snapshot *raft.Snapshot) error { - n := fmt.Sprintf("%016x%016x%016x.snap", snapshot.ClusterId, snapshot.Term, snapshot.Index) + fname := fmt.Sprintf("%016x-%016x-%016x.snap", snapshot.ClusterId, snapshot.Term, snapshot.Index) // TODO(xiangli): make raft.Snapshot a protobuf type b, err := json.Marshal(snapshot) if err != nil { @@ -43,7 +43,7 @@ func (s *Snapshotter) Save(snapshot *raft.Snapshot) error { if err != nil { return err } - return ioutil.WriteFile(path.Join(s.dir, n), d, 0666) + return ioutil.WriteFile(path.Join(s.dir, fname), d, 0666) } func (s *Snapshotter) Load() (*raft.Snapshot, error) { diff --git a/snap/snapshotter_test.go b/snap/snapshotter_test.go index 2d56aff94..4e43e25b3 100644 --- a/snap/snapshotter_test.go +++ b/snap/snapshotter_test.go @@ -64,7 +64,7 @@ func TestFailback(t *testing.T) { os.Mkdir(dir, 0700) defer os.RemoveAll(dir) - large := fmt.Sprintf("%016x%016x%016x.snap", 0xFFFF, 0xFFFF, 0xFFFF) + large := fmt.Sprintf("%016x-%016x-%016x.snap", 0xFFFF, 0xFFFF, 0xFFFF) err := ioutil.WriteFile(path.Join(dir, large), []byte("bad data"), 0666) if err != nil { t.Fatal(err)