From 9cd7ab75e8d0be2523e5c7f934991d665b867874 Mon Sep 17 00:00:00 2001 From: Gabriel Simmer Date: Mon, 23 Mar 2020 10:53:58 +0000 Subject: [PATCH] Better error messages for Backblaze, int64. Ran into an issue when running on a Raspberry Pi - occaisonally, the int size for the files being provided from Backblaze (which is in bytes) will be too large. This is fixed by upgrading the int to int64. As a part of this debugging process, I upgraded the error handling when fetching the Backblaze file listing to actually print the errors rather than failing silently. --- files/backblaze.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/files/backblaze.go b/files/backblaze.go index 636ab51..2fb839c 100644 --- a/files/backblaze.go +++ b/files/backblaze.go @@ -25,10 +25,10 @@ type BackblazeAuthPayload struct { type BackblazeFile struct { Action string `json:"action"` - Size int `json:"contentLength"` + Size int64 `json:"contentLength"` Type string `json:"contentType"` FileName string `json:"fileName"` - Timestamp int `json:"uploadTimestamp"` + Timestamp int64 `json:"uploadTimestamp"` } type BackblazeFilePayload struct { @@ -92,16 +92,19 @@ func (bp *BackblazeProvider) GetDirectory(path string) Directory { bp.Location + "/b2api/v2/b2_list_file_names", bytes.NewBuffer([]byte(requestBody))) if err != nil { + fmt.Println(err.Error()) return Directory{} } req.Header.Add("Authorization", bp.Authentication) resp, err := client.Do(req) if err != nil { + fmt.Println(err.Error()) return Directory{} } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { + fmt.Println(err.Error()) return Directory{} }