MCPcopy Create free account
hub / github.com/OpenListTeam/OpenList / head

Method head

internal/stream/stream.go:370–389  ·  view source on GitHub ↗
(p []byte)

Source from the content-addressed store, hash-verified

368}
369
370func (c *headCache) head(p []byte) (int, error) {
371 n := 0
372 for _, buf := range c.bufs {
373 n += copy(p[n:], buf)
374 if n == len(p) {
375 return n, nil
376 }
377 }
378 nn, err := io.ReadFull(c.reader, p[n:])
379 if nn > 0 {
380 buf := make([]byte, nn)
381 copy(buf, p[n:])
382 c.bufs = append(c.bufs, buf)
383 n += nn
384 if err == io.ErrUnexpectedEOF {
385 err = io.EOF
386 }
387 }
388 return n, err
389}
390
391func (r *headCache) Close() error {
392 clear(r.bufs)

Callers 1

ReadAtMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected