diff --git a/build.zig b/build.zig index b584c7d..0816d22 100644 --- a/build.zig +++ b/build.zig @@ -334,12 +334,14 @@ fn DownloadStep(comptime link: []const u8) type { return self; } - pub fn getOutputPath(self: *Self) !struct { path: []const u8, hash: u64 } { - var hasher = std.hash.Wyhash.init(0); + const Algo = std.crypto.hash.sha2.Sha256; + pub fn getOutputPath(self: *Self) !struct { path: []const u8, hash: [Algo.digest_length]u8 } { + var hasher = Algo.init(.{}); hasher.update(download_link); - const cache_hash = hasher.final(); + var cache_hash: [Algo.digest_length]u8 = undefined; + hasher.final(&cache_hash); - const cache_dir = try std.fs.path.join(self.builder.allocator, &[_][]const u8{ self.builder.cache_root.path.?, "o", try std.fmt.allocPrint(self.builder.allocator, "{x}", .{cache_hash}), fileNameNoExtension() }); + const cache_dir = try std.fs.path.join(self.builder.allocator, &[_][]const u8{ self.builder.cache_root.path.?, "o", try std.fmt.allocPrint(self.builder.allocator, "{s}", .{std.fmt.bytesToHex(cache_hash, .lower)}), fileNameNoExtension() }); return .{ .path = cache_dir, @@ -354,11 +356,12 @@ fn DownloadStep(comptime link: []const u8) type { const model_dir = fileNameNoExtension(); // Create a cache hash based on the URL - var hasher = std.hash.Wyhash.init(0); + var hasher = Algo.init(.{}); hasher.update(link); - const cache_hash = hasher.final(); + var cache_hash: [Algo.digest_length]u8 = undefined; + hasher.final(&cache_hash); - const cache_dir = try std.fs.path.join(self.builder.allocator, &[_][]const u8{ self.builder.cache_root.path.?, "o", try std.fmt.allocPrint(self.builder.allocator, "{x}", .{cache_hash}) }); + const cache_dir = try std.fs.path.join(self.builder.allocator, &[_][]const u8{ self.builder.cache_root.path.?, "o", try std.fmt.allocPrint(self.builder.allocator, "{s}", .{std.fmt.bytesToHex(cache_hash, .lower)}) }); const cached_model_dir = try std.fs.path.join( self.builder.allocator,