mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-09 23:24:05 -08:00
move version check into newReader()
This commit is contained in:
parent
faecfac2fa
commit
618bceadb4
|
@ -577,10 +577,6 @@ func NewReader(b ByteSlice, version int) (*Reader, error) {
|
|||
|
||||
// NewFileReader returns a new index reader against the given index file.
|
||||
func NewFileReader(path string, version int) (*Reader, error) {
|
||||
if version != 1 && version != 2 {
|
||||
return nil, errors.Errorf("unexpected file version %d", version)
|
||||
|
||||
}
|
||||
f, err := fileutil.OpenMmapFile(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -598,6 +594,11 @@ func newReader(b ByteSlice, c io.Closer, version int) (*Reader, error) {
|
|||
crc32: newCRC32(),
|
||||
version: version,
|
||||
}
|
||||
|
||||
if version != 1 && version != 2 {
|
||||
return nil, errors.Errorf("unexpected file version %d", version)
|
||||
|
||||
}
|
||||
// Verify magic number.
|
||||
if b.Len() < 4 {
|
||||
return nil, errors.Wrap(errInvalidSize, "index header")
|
||||
|
|
Loading…
Reference in a new issue