app/publisher/js: support for sha224 hashes (#1293)

Fixes #1292
This commit is contained in:
Attila Tajti 2019-12-27 21:59:25 +01:00 committed by mpl
parent 67333e3a9c
commit 9a1336816a
1 changed files with 4 additions and 2 deletions

View File

@ -161,7 +161,7 @@ func newFileItemContainer(thumbHeight int) (*fileItemContainer, error) {
parent = root
} else {
_, parentPrefixPath := path.Split(basePath)
parentPrefix := "sha1-" + strings.TrimPrefix(parentPrefixPath, "h")
parentPrefix := strings.TrimPrefix(parentPrefixPath, "h")
parent, err = getFullRef(scheme, host, prefix, parentPrefix)
if err != nil {
return nil, err
@ -251,7 +251,9 @@ func (fic *fileItemContainer) populate() error {
func getFullRef(scheme, host, pathPrefix, digestPrefix string) (blob.Ref, error) {
var br blob.Ref
query := fmt.Sprintf(`{"constraint":{"blobRefPrefix": "%s"}}`, digestPrefix)
ca := fmt.Sprintf(`{"blobRefPrefix":"sha224-%s"}`, digestPrefix)
cb := fmt.Sprintf(`{"blobRefPrefix":"sha1-%s"}`, digestPrefix)
query := fmt.Sprintf(`{"constraint":{"logical":{"op":"or","a":%s,"b":%s}}}`, ca, cb)
resp, err := http.Post(fmt.Sprintf("%s://%s%ssearch", scheme, host, pathPrefix), "application/json", strings.NewReader(query))
if err != nil {
return br, err