-
-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better receive progress for directories
We now account for the decompression as well and not just set it to done.
- Loading branch information
Showing
2 changed files
with
31 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package util | ||
|
||
import ( | ||
"io" | ||
) | ||
|
||
type teeReaderAt struct { | ||
r io.ReaderAt | ||
w io.Writer | ||
} | ||
|
||
// ReadAt wraps the reader and calls write on it. | ||
func (t *teeReaderAt) ReadAt(p []byte, off int64) (int, error) { | ||
n, err := t.r.ReadAt(p, off) | ||
if n > 0 { | ||
if n, err := t.w.Write(p[:n]); err != nil { | ||
return n, err | ||
} | ||
} | ||
|
||
return n, err | ||
} | ||
|
||
// TeeReaderAt returns a wrapped ReaderAt that writes what is being read. | ||
func TeeReaderAt(r io.ReaderAt, w io.Writer) io.ReaderAt { | ||
return &teeReaderAt{r, w} | ||
} |