MCPcopy
hub / github.com/containerd/containerd / CopyReaderAt

Function CopyReaderAt

core/content/helpers.go:237–252  ·  view source on GitHub ↗

CopyReaderAt copies to a writer from a given reader at for the given number of bytes. This copy does not commit the writer.

(cw Writer, ra ReaderAt, n int64)

Source from the content-addressed store, hash-verified

235// CopyReaderAt copies to a writer from a given reader at for the given
236// number of bytes. This copy does not commit the writer.
237func CopyReaderAt(cw Writer, ra ReaderAt, n int64) error {
238 ws, err := cw.Status()
239 if err != nil {
240 return err
241 }
242
243 copied, err := copyWithBuffer(cw, io.NewSectionReader(ra, ws.Offset, n))
244 if err != nil {
245 return fmt.Errorf("failed to copy: %w", err)
246 }
247 if copied < n {
248 // Short writes would return its own error, this indicates a read failure
249 return fmt.Errorf("failed to read expected number of bytes: %w", io.ErrUnexpectedEOF)
250 }
251 return nil
252}
253
254// CopyReader copies to a writer from a given reader, returning
255// the number of bytes copied.

Callers 1

createAndCopyMethod · 0.92

Calls 2

copyWithBufferFunction · 0.85
StatusMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…