From 38d6b207cc47976934fe2c4fb4fa1709eaddab2a Mon Sep 17 00:00:00 2001 From: Libo Huang Date: Thu, 7 Nov 2024 17:20:14 +0800 Subject: [PATCH] error log --- partial/downloader.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/partial/downloader.go b/partial/downloader.go index 9491a01..ffda6b8 100644 --- a/partial/downloader.go +++ b/partial/downloader.go @@ -4,6 +4,7 @@ import ( "context" "errors" "io" + "log" "os" "sync" ) @@ -116,6 +117,7 @@ func (p *MultiPartialDownloader) Download() error { chunksSorter.Write(chunk) if err != nil { + log.Printf("part %d, error: %s", chunk.index, err) return } } @@ -135,7 +137,11 @@ func (p *MultiPartialDownloader) Download() error { if len(chunk.Data()) == 0 { return errors.New("chunk buffer download but size is 0") } - p.writer.Write(chunk.Data()) + _, err := p.writer.Write(chunk.Data()) + if err != nil { + log.Printf("part %d, error: %s", chunk.index, err) + return err + } } return nil }