From 9476a44a4319d01afd73f3ce4e996c5606d3eccd Mon Sep 17 00:00:00 2001 From: Paul Hebble Date: Tue, 30 Jul 2024 14:41:53 -0500 Subject: [PATCH] Omit sha1 hash for spec versions newer than v1.34 --- Netkan/Transformers/DownloadAttributeTransformer.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Netkan/Transformers/DownloadAttributeTransformer.cs b/Netkan/Transformers/DownloadAttributeTransformer.cs index 6428d8df9a..c3443f8d41 100644 --- a/Netkan/Transformers/DownloadAttributeTransformer.cs +++ b/Netkan/Transformers/DownloadAttributeTransformer.cs @@ -1,7 +1,10 @@ using System; using System.Collections.Generic; + using log4net; using Newtonsoft.Json.Linq; + +using CKAN.Versioning; using CKAN.NetKAN.Extensions; using CKAN.NetKAN.Model; using CKAN.NetKAN.Services; @@ -45,8 +48,12 @@ public IEnumerable Transform(Metadata metadata, TransformOptions opts) json["download_hash"] = new JObject(); var download_hashJson = (JObject)json["download_hash"]; - Log.Debug("Calculating download SHA1..."); - download_hashJson.SafeAdd("sha1", _fileService.GetFileHashSha1(file)); + // Older clients will complain if download_hash is set without sha1 + if (metadata.SpecVersion <= v1p34) + { + Log.Debug("Calculating download SHA1..."); + download_hashJson.SafeAdd("sha1", _fileService.GetFileHashSha1(file)); + } Log.Debug("Calculating download SHA256..."); download_hashJson.SafeAdd("sha256", _fileService.GetFileHashSha256(file)); @@ -63,5 +70,6 @@ public IEnumerable Transform(Metadata metadata, TransformOptions opts) yield return metadata; } } + private static readonly ModuleVersion v1p34 = new ModuleVersion("v1.34"); } }