diff --git a/tools/knowledge.cs b/tools/knowledge.cs index 0c605b7..406a264 100644 --- a/tools/knowledge.cs +++ b/tools/knowledge.cs @@ -59,7 +59,7 @@ using (var input = File.OpenRead(download)) using (var file = File.Create(Path.Combine(output, "ip2asn.bin"))) AsnTable.Write(file, sourceDate, Sources.IpToAsn(input)); foreach (var stale in new[] { "networks.bin", "carriers.json", "registry.bin" }) File.Delete(Path.Combine(output, stale)); -string sha; +var sha = default(string); using (var input = File.OpenRead(download)) sha = Convert.ToHexStringLower(SHA256.HashData(input)); File.WriteAllText(Path.Combine(output, "SOURCE.txt"), $"iptoasn.com, Public Domain Dedication and License (PDDL) 1.0\n{Fallback}\nlast-modified {sourceDate:O}\nsha256 {sha}\n"); Report(); diff --git a/tools/release.cs b/tools/release.cs index 609d212..1d21940 100644 --- a/tools/release.cs +++ b/tools/release.cs @@ -365,7 +365,7 @@ string Reset(string folder) return folder; } -string Size(string file) => $"{new FileInfo(file).Length / 1024.0 / 1024.0:0.0} MB"; +string Size(string file) => $"{new FileInfo(file).Length.ToMegabytes()} MB"; string Option(string key) { @@ -404,3 +404,8 @@ static string FindRoot() while (dir is not null && !File.Exists(Path.Combine(dir.FullName, "MeWeb.slnx"))) dir = dir.Parent; return dir?.FullName ?? throw new InvalidOperationException("run from inside the repository (MeWeb.slnx not found)"); } + +static class NumbersExtensions +{ + public static string ToMegabytes(this long bytes) => (bytes / 1048576.0).ToString("0.0", System.Globalization.CultureInfo.InvariantCulture); +}