fix: if upload status code isn't 200, make it an err based on the body

This commit is contained in:
Derrick Hammer 2023-05-04 07:58:06 -04:00
parent fbc9133df5
commit 039a4a3354
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 7 additions and 2 deletions

View File

@ -84,12 +84,17 @@ func (f *FilesService) PostUpload() {
}
ret, err := client.R().SetBody(file).Put(fmt.Sprintf("/worker/objects/%s", hashHex))
if ret.StatusCode() != 200 {
err = errors.New(string(ret.Body()))
}
if internalError(ctx, err) {
return
}
fmt.Println(ret)
_, err = client.R().SetBody(tree).Put(fmt.Sprintf("/worker/objects/%s.obao", hashHex))
ret, err = client.R().SetBody(tree).Put(fmt.Sprintf("/worker/objects/%s.obao", hashHex))
if ret.StatusCode() != 200 {
err = errors.New(string(ret.Body()))
}
if internalError(ctx, err) {
return
}