Skip to content

Commit

Permalink
Check calcHash() for errors when creating buffer
Browse files Browse the repository at this point in the history
Even though we only call calcHash() if `size > LargeFileThreshold` is
false, it may still return ErrFileTooLarge if `size` is smaller than
the actual size of the file that we've just read from disk, i.e. if the
file on disk has increased since we checked it via os.Stat().
  • Loading branch information
dmaluka committed Aug 17, 2024
1 parent 5e8253e commit bc5e24b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion internal/buffer/buffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,10 @@ func NewBuffer(r io.Reader, size int64, path string, startcursor Loc, btype BufT
} else if !hasBackup {
// since applying a backup does not save the applied backup to disk, we should
// not calculate the original hash based on the backup data
calcHash(b, &b.origHash)
err := calcHash(b, &b.origHash)
if err == ErrFileTooLarge {
b.Settings["fastdirty"] = true
}
}
}

Expand Down

0 comments on commit bc5e24b

Please sign in to comment.