Cache busting for resources.Copy

I want to combine both JPG and webp, but either one works and the other fails or vice versa. It is related to this topic where I asked the same question, but you told me to experiment, which has not been a success so far (I’ve spent weeks on this). My code so far (for the templates, as I’ve not yet revisited the render hook).

{{- with or (.Resources.GetMatch "cover.*")  (resources.Get "image/thumbnail.jpg") }}
  {{- $base := strings.TrimRight (path.Ext .Key) .Key }}
  {{- $jpgExt := path.Ext .Key }}
  {{- with .Fill (printf "%dx%d webp TopLeft" (div .Width 2) (div .Height 1.45 | int) ) | fingerprint }}
    {{- $webpExt := path.Ext .Key  }}
    {{- $targetImg := printf "%s-%d%s" $base (crypto.FNV32a .Data.Integrity) $jpgExt }}
    {{- $targetWebp := printf "%s-%d%s" $base (crypto.FNV32a .Data.Integrity) $webpExt }}
    {{- with or (resources.Copy $targetWebp .) (resources.Copy $targetImg .)  }}
    <picture>
      <source srcset="{{ .RelPermalink }}" type="image/webp">
      <img  src="{{ $targetImg }}" width="{{ .Width }}" height="{{ .Height }}" alt="" fetchpriority="high">
    </picture>
    {{- end }}
  {{- end }}
{{- end }}

(Here, the webP image works, but the JPG one returns a 404 upon running hugo --gc).