refactor: use CIDFromHash and extract the hash

This commit is contained in:
Derrick Hammer 2024-03-21 15:57:05 -04:00
parent a48b10e50c
commit 62867f26a9
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 6 additions and 1 deletions

View File

@ -859,7 +859,12 @@ func (s *S5API) accountPins(jc jape.Context) {
pins := make([]AccountPin, len(pinsRet)) pins := make([]AccountPin, len(pinsRet))
for i, pin := range pinsRet { for i, pin := range pinsRet {
base64Url, err := encoding.NewMultihash(append([]byte{byte(types.HashTypeBlake3)}, pin.Upload.Hash...)).ToBase64Url() cid, err := encoding.CIDFromHash(pin.Upload.Hash, pin.Upload.Size, types.CIDTypeRaw, types.HashTypeBlake3)
if err != nil {
s.sendErrorResponse(jc, NewS5Error(ErrKeyInternalError, err))
return
}
base64Url, err := cid.Hash.ToBase64Url()
if err != nil { if err != nil {
s.sendErrorResponse(jc, NewS5Error(ErrKeyInternalError, err)) s.sendErrorResponse(jc, NewS5Error(ErrKeyInternalError, err))
return return