Skip to content

Commit

Permalink
Omit sha1 hash for spec versions newer than v1.34
Browse files Browse the repository at this point in the history
  • Loading branch information
HebaruSan committed Jul 30, 2024
1 parent 9bb15cd commit 9476a44
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Netkan/Transformers/DownloadAttributeTransformer.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -45,8 +48,12 @@ public IEnumerable<Metadata> 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));

Expand All @@ -63,5 +70,6 @@ public IEnumerable<Metadata> Transform(Metadata metadata, TransformOptions opts)
yield return metadata;
}
}
private static readonly ModuleVersion v1p34 = new ModuleVersion("v1.34");
}
}

0 comments on commit 9476a44

Please sign in to comment.