From 2cd367e9d9c77f8f34c1ab9770b3734f32f3df78 Mon Sep 17 00:00:00 2001 From: Yicheng Qin Date: Thu, 5 Jun 2014 12:09:25 -0700 Subject: [PATCH] fix(raft/log): truncate file and reset offset correctly --- third_party/github.com/goraft/raft/log.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/third_party/github.com/goraft/raft/log.go b/third_party/github.com/goraft/raft/log.go index 6e87da455..9bd3a6814 100644 --- a/third_party/github.com/goraft/raft/log.go +++ b/third_party/github.com/goraft/raft/log.go @@ -168,9 +168,10 @@ func (l *Log) open(path string) error { if err == io.EOF { debugln("open.log.append: finish ") } else { - if err = os.Truncate(path, readBytes); err != nil { + if err = l.file.Truncate(readBytes); err != nil { return fmt.Errorf("raft.Log: Unable to recover: %v", err) } + l.file.Seek(readBytes, os.SEEK_SET) } break }