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()
|
||||||
|
|
||||||
|
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()))
|
return upload, errors.New(fmt.Sprintf("error fetching file: %s", objectExistsResult.String()))
|
||||||
}
|
}
|
||||||
|
|
||||||
if objectExistsResult.StatusCode() != 404 {
|
statusCode = 404
|
||||||
return upload, errors.New("file already exists in network, but missing in database")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if statusCode != 404 {
|
||||||
return upload, err
|
msg := "file already exists in network, but missing in database"
|
||||||
|
shared.GetLogger().Error(msg)
|
||||||
|
return upload, errors.New(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
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