MCPcopy Index your code
hub / github.com/moby/moby / Read

Method Read

client/pkg/progress/progressreader.go:34–50  ·  view source on GitHub ↗
(buf []byte)

Source from the content-addressed store, hash-verified

32}
33
34func (p *Reader) Read(buf []byte) (int, error) {
35 read, err := p.in.Read(buf)
36 p.current += int64(read)
37 updateEvery := int64(1024 * 512) // 512kB
38 if p.size > 0 {
39 // Update progress for every 1% read if 1% < 512kB
40 if increment := int64(0.01 * float64(p.size)); increment < updateEvery {
41 updateEvery = increment
42 }
43 }
44 if p.current-p.lastUpdate > updateEvery || err != nil {
45 p.updateProgress(err != nil && read == 0)
46 p.lastUpdate = p.current
47 }
48
49 return read, err
50}
51
52// Close closes the progress reader and its underlying reader.
53func (p *Reader) Close() error {

Callers 2

GenerateRandomIDFunction · 0.45

Calls 1

updateProgressMethod · 0.95

Tested by 1