From b27ccf34bf4e5ee618a66fa11c68a9690e395034 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Sat, 27 Oct 2018 10:00:43 +0200 Subject: [PATCH] resource: Allow .Data.Integrity to be accessed on its own Fixes #5296 --- hugolib/resource_chain_test.go | 7 +++++++ resource/transform.go | 3 +++ 2 files changed, 10 insertions(+) diff --git a/hugolib/resource_chain_test.go b/hugolib/resource_chain_test.go index 1f55976f0..3a1fb040a 100644 --- a/hugolib/resource_chain_test.go +++ b/hugolib/resource_chain_test.go @@ -288,11 +288,18 @@ T2: {{ $result.Content }}|{{ $result.RelPermalink}}|{{$result.MediaType.Type }} T1: {{ $result.Content }}|{{ $result.RelPermalink}}|{{$result.MediaType.Type }}|{{ $result.Data.Integrity }}| T2: {{ $result512.Content }}|{{ $result512.RelPermalink}}|{{$result512.MediaType.Type }}|{{ $result512.Data.Integrity }}| T3: {{ $resultMD5.Content }}|{{ $resultMD5.RelPermalink}}|{{$resultMD5.MediaType.Type }}|{{ $resultMD5.Data.Integrity }}| +{{ $r2 := "bc" | resources.FromString "rocks/hugo2.txt" | fingerprint }} +{{/* https://github.com/gohugoio/hugo/issues/5296 */}} +T4: {{ $r2.Data.Integrity }}| + + `) }, func(b *sitesBuilder) { b.AssertFileContent("public/index.html", `T1: ab|/rocks/hugo.fb8e20fc2e4c3f248c60c39bd652f3c1347298bb977b8b4d5903b85055620603.txt|text/plain|sha256-+44g/C5MPySMYMOb1lLzwTRymLuXe4tNWQO4UFViBgM=|`) b.AssertFileContent("public/index.html", `T2: ab|/rocks/hugo.2d408a0717ec188158278a796c689044361dc6fdde28d6f04973b80896e1823975cdbf12eb63f9e0591328ee235d80e9b5bf1aa6a44f4617ff3caf6400eb172d.txt|text/plain|sha512-LUCKBxfsGIFYJ4p5bGiQRDYdxv3eKNbwSXO4CJbhgjl1zb8S62P54FkTKO4jXYDptb8apqRPRhf/PK9kAOsXLQ==|`) b.AssertFileContent("public/index.html", `T3: ab|/rocks/hugo.187ef4436122d1cc2f40dc2b92f0eba0.txt|text/plain|md5-GH70Q2Ei0cwvQNwrkvDroA==|`) + b.AssertFileContent("public/index.html", `T4: sha256-Hgu9bGhroFC46wP/7txk/cnYCUf86CGrvl1tyNJSxaw=|`) + }}, {"template", func() bool { return true }, func(b *sitesBuilder) {}, func(b *sitesBuilder) { }}, diff --git a/resource/transform.go b/resource/transform.go index d3a215467..a4b1ca27c 100644 --- a/resource/transform.go +++ b/resource/transform.go @@ -231,6 +231,9 @@ func (r *transformedResource) Content() (interface{}, error) { } func (r *transformedResource) Data() interface{} { + if err := r.initTransform(false); err != nil { + return noData + } return r.MetaData }