| author | |
| committer | |
| log | 2ffb060cfc4052fd3345536913d6fe15b4826b54 |
| tree | 50503e08568595dc29dcbcc2b7be34045b5c3232 |
| parent | a8590c12cf668eb7becd862fc10cd8f77ad003a5 |
2 files changed, 3 insertions(+), 3 deletions(-)
src/common.zig+1-1| ... | ... | @@ -181,7 +181,7 @@ pub fn get_modpath(cachepath: string, d: zigmod.Dep, options: *CollectOptions) ! |
| 181 | 181 | } |
| 182 | 182 | const file_path = try std.fs.path.join(gpa, &.{ pv, file_name }); |
| 183 | 183 | try d.type.pull(gpa, d.path, pv); |
| 184 | if (try u.validate_hash(d.version, file_path)) { | |
| 184 | if (try u.validate_hash(gpa, d.version, file_path)) { | |
| 185 | 185 | try std.fs.cwd().deleteFile(file_path); |
| 186 | 186 | return pv; |
| 187 | 187 | } |
src/util/funcs.zig+2-2| ... | ... | @@ -207,11 +207,11 @@ pub const HashFn = enum { |
| 207 | 207 | sha512, |
| 208 | 208 | }; |
| 209 | 209 | |
| 210 | pub fn validate_hash(input: string, file_path: string) !bool { | |
| 210 | pub fn validate_hash(alloc: *std.mem.Allocator, input: string, file_path: string) !bool { | |
| 211 | 211 | const hash = parse_split(HashFn, "-").do(input) catch return false; |
| 212 | 212 | const file = try std.fs.cwd().openFile(file_path, .{}); |
| 213 | 213 | defer file.close(); |
| 214 | const data = try file.reader().readAllAlloc(gpa, gb); | |
| 214 | const data = try file.reader().readAllAlloc(alloc, gb); | |
| 215 | 215 | const expected = hash.string; |
| 216 | 216 | const actual = switch (hash.id) { |
| 217 | 217 | .blake3 => try do_hash(std.crypto.hash.Blake3, data), |