bisync: fix endless loop if lockfile decoder errors

Before this change, the decoder looked only for `io.EOF`, and if any other error
was returned, it could cause an infinite loop. This change fixes the issue by
breaking for any non-nil error.
This commit is contained in:
nielash 2024-04-09 07:17:00 -04:00 committed by Nick Craig-Wood
parent bef9fd0bc3
commit 04128f97ee
1 changed files with 4 additions and 1 deletions

View File

@ -99,7 +99,10 @@ func (b *bisyncRun) lockFileIsExpired() bool {
b.handleErr(b.lockFile, "error reading lock file", err, true, true)
dec := json.NewDecoder(rdf)
for {
if err := dec.Decode(&data); err == io.EOF {
if err := dec.Decode(&data); err != nil {
if err != io.EOF {
fs.Errorf(b.lockFile, "err: %v", err)
}
break
}
}