fix(blossom): handle nil BlobDescriptor in Get and Delete

Refine extension derivation logic by ensuring `bd` is not nil before
accessing its type.
This commit is contained in:
Anthony Accioly
2025-08-07 02:56:56 +01:00
committed by fiatjaf_
parent 3c802caff5
commit 668c41b988

View File

@@ -189,11 +189,11 @@ func (bs BlossomServer) handleGetBlob(w http.ResponseWriter, r *http.Request) {
var ext string
bd, err := bs.Store.Get(r.Context(), hhash)
if err != nil {
// can't find the blob, try to get the extension from the URL
// can't find the BlobDescriptor, try to get the extension from the URL
if len(spl) == 2 {
ext = spl[1]
}
} else {
} else if bd != nil {
ext = getExtension(bd.Type)
}
@@ -348,11 +348,11 @@ func (bs BlossomServer) handleDelete(w http.ResponseWriter, r *http.Request) {
var ext string
bd, err := bs.Store.Get(r.Context(), hhash)
if err != nil {
// can't find the blob, try to get the extension from the URL
// can't find the BlobDescriptor, try to get the extension from the URL
if len(spl) == 2 {
ext = spl[1]
}
} else {
} else if bd != nil {
ext = getExtension(bd.Type)
}