commit 0faa5bb3f921608f8feaf0fdd3f9895f57e68822
parent e3f78c6fedfe5d13532d66bae7b794b8f7b7fe6d
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Fri, 3 Feb 2023 17:35:06 -0800
check all client side errors
Diffstat:
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/cmd/dkfdownload/main.go b/cmd/dkfdownload/main.go
@@ -207,7 +207,10 @@ func work(i int, wg *sync.WaitGroup, baseUrl, filedropUUID string, chunksCh chan
start = time.Now()
body := url.Values{}
body.Set("chunk", strconv.FormatInt(chunkNum, 10))
- req, _ := http.NewRequest(http.MethodPost, baseUrl+"/file-drop/"+filedropUUID+"/dkfdownload", strings.NewReader(body.Encode()))
+ req, err := http.NewRequest(http.MethodPost, baseUrl+"/file-drop/"+filedropUUID+"/dkfdownload", strings.NewReader(body.Encode()))
+ if err != nil {
+ return err
+ }
req.Header.Set("User-Agent", userAgent)
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
resp, err := client.Do(req)
@@ -227,7 +230,9 @@ func work(i int, wg *sync.WaitGroup, baseUrl, filedropUUID string, chunksCh chan
return err
}
defer f.Close()
- _, _ = io.Copy(f, resp.Body)
+ if _, err = io.Copy(f, resp.Body); err != nil {
+ return err
+ }
return nil
})
newChunksCompleted := atomic.AddInt64(&chunksCompleted, 1)