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

This commit is contained in:
Yicheng Qin
2014-06-05 12:09:25 -07:00
parent a974bbfe4f
commit 2cd367e9d9

View File

@@ -168,9 +168,10 @@ func (l *Log) open(path string) error {
if err == io.EOF { if err == io.EOF {
debugln("open.log.append: finish ") debugln("open.log.append: finish ")
} else { } 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) return fmt.Errorf("raft.Log: Unable to recover: %v", err)
} }
l.file.Seek(readBytes, os.SEEK_SET)
} }
break break
} }