fix: if uploading returns a 500 and its a slab error, treat as a 404
This commit is contained in:
parent
bef2ed7431
commit
6ddef03790
|
@ -59,16 +59,22 @@ func Upload(r io.ReadSeeker, size int64) (model.Upload, error) {
|
||||||
return upload, err
|
return upload, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if objectExistsResult.StatusCode() == 500 {
|
statusCode := objectExistsResult.StatusCode()
|
||||||
return upload, errors.New(fmt.Sprintf("error fetching file: %s", objectExistsResult.String()))
|
|
||||||
|
if statusCode == 500 {
|
||||||
|
bodyErr := objectExistsResult.String()
|
||||||
|
if !strings.Contains(bodyErr, "no slabs found") {
|
||||||
|
shared.GetLogger().Error("Failed fetching object", zap.String("error", objectExistsResult.String()))
|
||||||
|
return upload, errors.New(fmt.Sprintf("error fetching file: %s", objectExistsResult.String()))
|
||||||
|
}
|
||||||
|
|
||||||
|
statusCode = 404
|
||||||
}
|
}
|
||||||
|
|
||||||
if objectExistsResult.StatusCode() != 404 {
|
if statusCode != 404 {
|
||||||
return upload, errors.New("file already exists in network, but missing in database")
|
msg := "file already exists in network, but missing in database"
|
||||||
}
|
shared.GetLogger().Error(msg)
|
||||||
|
return upload, errors.New(msg)
|
||||||
if err != nil {
|
|
||||||
return upload, err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ret, err := client.R().SetBody(r).Put(fmt.Sprintf("/worker/objects/%s", hashHex))
|
ret, err := client.R().SetBody(r).Put(fmt.Sprintf("/worker/objects/%s", hashHex))
|
||||||
|
|
Loading…
Reference in New Issue