diff options
author | Keuin <[email protected]> | 2022-09-08 00:54:21 +0800 |
---|---|---|
committer | Keuin <[email protected]> | 2022-09-08 00:54:21 +0800 |
commit | 1009e88ff752525966708c56190c2dfa32bc9537 (patch) | |
tree | 42bc6d6fb3ab09b4326f4256a18b24ce5eb1ad29 /common/copy.go | |
parent | ffdd3af907215bbeb4c470244643f2337261c2f8 (diff) |
Remove unnecessary boolean flag.
Diffstat (limited to 'common/copy.go')
-rw-r--r-- | common/copy.go | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/common/copy.go b/common/copy.go index a896fb4..6f47a62 100644 --- a/common/copy.go +++ b/common/copy.go @@ -18,10 +18,7 @@ func (rf readerFunc) Read(p []byte) (n int, err error) { return rf(p) } // Copy slightly modified function signature: // - context has been added in order to propagate cancellation // - (undo by Keuin) I do not return the number of bytes written, has it is not useful in my use case -// - (added by Keuin) add a isCancelled return value indicating the copy is stopped by cancelling the context -func Copy(ctx context.Context, out io.Writer, in io.Reader) (written int64, err error, isCancelled bool) { - isCancelled = false - +func Copy(ctx context.Context, out io.Writer, in io.Reader) (written int64, err error) { // Copy will call the Reader and Writer interface multiple time, in order // to copy by chunk (avoiding loading the whole file in memory). // I insert the ability to cancel before read time as it is the earliest @@ -34,7 +31,6 @@ func Copy(ctx context.Context, out io.Writer, in io.Reader) (written int64, err // if context has been canceled case <-ctx.Done(): // stop process and propagate "context canceled" error - isCancelled = true return 0, ctx.Err() default: // otherwise just run default io.Reader implementation |