Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions util/streamutils/streamutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (s *sXZReadAheadReader) Read(buf []byte) (int, error) {
}
}

func StreamPipe(upstream io.Reader, writer io.Writer, CalChecksum bool, callback func(saved int64)) (*SStreamProperty, error) {
func StreamPipe(upstream io.Reader, writer io.Writer, CalChecksum bool, callback func(savedTotal int64, savedOnce int64)) (*SStreamProperty, error) {
sp := SStreamProperty{}

var md5sum hash.Hash
Expand Down Expand Up @@ -103,6 +103,9 @@ func StreamPipe(upstream io.Reader, writer io.Writer, CalChecksum bool, callback
n, err := reader.Read(buf)
if n > 0 {
sp.Size += int64(n)
if callback != nil {
callback(sp.Size, int64(n))
}
if CalChecksum {
md5sum.Write(buf[:n])
}
Expand All @@ -114,9 +117,6 @@ func StreamPipe(upstream io.Reader, writer io.Writer, CalChecksum bool, callback
}
offset += m
}
if callback != nil {
callback(sp.Size)
}
}
if err != nil {
if err == io.EOF {
Expand Down