mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-26 22:19:40 -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.
|
// NewFileReader returns a new index reader against the given index file.
|
||||||
func NewFileReader(path string, version int) (*Reader, error) {
|
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)
|
f, err := fileutil.OpenMmapFile(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -598,6 +594,11 @@ func newReader(b ByteSlice, c io.Closer, version int) (*Reader, error) {
|
||||||
crc32: newCRC32(),
|
crc32: newCRC32(),
|
||||||
version: version,
|
version: version,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if version != 1 && version != 2 {
|
||||||
|
return nil, errors.Errorf("unexpected file version %d", version)
|
||||||
|
|
||||||
|
}
|
||||||
// Verify magic number.
|
// Verify magic number.
|
||||||
if b.Len() < 4 {
|
if b.Len() < 4 {
|
||||||
return nil, errors.Wrap(errInvalidSize, "index header")
|
return nil, errors.Wrap(errInvalidSize, "index header")
|
||||||
|
|
Loading…
Reference in a new issue