From 1009e88ff752525966708c56190c2dfa32bc9537 Mon Sep 17 00:00:00 2001 From: Keuin Date: Thu, 8 Sep 2022 00:54:21 +0800 Subject: Remove unnecessary boolean flag. --- bilibili/streaming.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'bilibili/streaming.go') diff --git a/bilibili/streaming.go b/bilibili/streaming.go index ec99565..5407043 100644 --- a/bilibili/streaming.go +++ b/bilibili/streaming.go @@ -3,6 +3,7 @@ package bilibili import ( "bilibili-livestream-archiver/common" "context" + "errors" "fmt" "io" "net/http" @@ -59,14 +60,13 @@ func (b Bilibili) CopyLiveStream( defer cancelGuardian() // blocking copy - n, err, isCancelled := common.Copy(ctx, out, resp.Body) + n, err := common.Copy(ctx, out, resp.Body) - if isCancelled { + if errors.Is(err, context.Canceled) { // cancelled by context // this error is useless err = nil - } - if !isCancelled && err != nil { + } else { // real error happens b.error.Printf("Stream copying was interrupted unexpectedly: %v", err) } -- cgit v1.2.3