fix a logic error in log open
parent
7411d38154
commit
b01e3e713e
6
log.go
6
log.go
|
@ -171,13 +171,13 @@ func (l *Log) open(path string) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
debugln("open.log.append: finish ")
|
debugln("open.log.append: finish ")
|
||||||
break
|
} else {
|
||||||
}
|
|
||||||
|
|
||||||
if err = os.Truncate(path, readBytes); err != nil {
|
if err = os.Truncate(path, readBytes); err != nil {
|
||||||
return fmt.Errorf("raft.Log: Unable to recover: %v", err)
|
return fmt.Errorf("raft.Log: Unable to recover: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
// Append entry.
|
// Append entry.
|
||||||
l.entries = append(l.entries, entry)
|
l.entries = append(l.entries, entry)
|
||||||
|
|
|
@ -86,7 +86,7 @@ func (e *LogEntry) decode(r io.Reader) (int, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
data := make([]byte, length)
|
data := make([]byte, length)
|
||||||
num, err := r.Read(data)
|
_, err = r.Read(data)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
|
Loading…
Reference in New Issue