CopyWithCallback copies reader to writer while performing a progress callback
(writer io.Writer, reader io.Reader, totalSize int64, cb CopyCallback)
| 21 | |
| 22 | // CopyWithCallback copies reader to writer while performing a progress callback |
| 23 | func 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 |
| 43 | func NewLfsContentHash() hash.Hash { |