Browse Source

fix(raft/log): truncate file and reset offset correctly

Yicheng Qin 11 years ago
parent
commit
2cd367e9d9
1 changed files with 2 additions and 1 deletions
  1. 2 1
      third_party/github.com/goraft/raft/log.go

+ 2 - 1
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
 		}