1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
package fetch
import (
"io"
"lindenii.org/go/furgit/errs"
oid "lindenii.org/go/furgit/object/id"
"lindenii.org/go/furgit/object/typ"
)
// exactReader reads one object's content stream
// and verifies that its header type matches wantType.
func (fetcher *Fetcher) exactReader(id oid.ObjectID, wantType typ.Type) (io.ReadCloser, int, error) {
gotType, size, rc, err := fetcher.store.ReadReaderContent(id)
if err != nil {
return nil, 0, wrapObjectReadError(id, err)
}
if gotType != wantType {
_ = rc.Close()
return nil, 0, &errs.ObjectTypeError{OID: id, Got: gotType, Want: wantType}
}
return rc, size, nil
}
|