From 9a1336816afdfcf36ae0ec3705e5ae4053748f10 Mon Sep 17 00:00:00 2001 From: Attila Tajti Date: Fri, 27 Dec 2019 21:59:25 +0100 Subject: [PATCH] app/publisher/js: support for sha224 hashes (#1293) Fixes #1292 --- app/publisher/js/file.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/publisher/js/file.go b/app/publisher/js/file.go index 4d991f236..7a7c4e83a 100644 --- a/app/publisher/js/file.go +++ b/app/publisher/js/file.go @@ -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