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.
This commit is contained in:
Gabriel Simmer 2020-03-23 10:53:58 +00:00
parent f54ad74ec7
commit 9cd7ab75e8
No known key found for this signature in database
GPG key ID: 33BA4D83B160A0A9

View file

@ -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{}
}