MCPcopy
hub / github.com/git-lfs/git-lfs / CopyWithCallback

Function CopyWithCallback

tools/iotools.go:23–40  ·  view source on GitHub ↗

CopyWithCallback copies reader to writer while performing a progress callback

(writer io.Writer, reader io.Reader, totalSize int64, cb CopyCallback)

Source from the content-addressed store, hash-verified

21
22// CopyWithCallback copies reader to writer while performing a progress callback
23func CopyWithCallback(writer io.Writer, reader io.Reader, totalSize int64, cb CopyCallback) (int64, error) {
24 if success, _ := CloneFile(writer, reader); success {
25 if cb != nil {
26 cb(totalSize, totalSize, 0)
27 }
28 return totalSize, nil
29 }
30 if cb == nil {
31 return io.Copy(writer, reader)
32 }
33
34 cbReader := &CallbackReader{
35 C: cb,
36 TotalSize: totalSize,
37 Reader: reader,
38 }
39 return io.Copy(writer, cbReader)
40}
41
42// Get a new Hash instance of the type used to hash LFS content
43func NewLfsContentHash() hash.Hash {

Callers 7

copyToTempMethod · 0.92
readLocalFileMethod · 0.92
performDownloadFunction · 0.92
performCopyFunction · 0.92
downloadMethod · 0.92
doDownloadMethod · 0.92
TestCopyWithCallbackFunction · 0.85

Calls 1

CloneFileFunction · 0.70

Tested by 1

TestCopyWithCallbackFunction · 0.68