From be69e8e871d26973c644cfad5225ae9e337179c9 Mon Sep 17 00:00:00 2001 From: LeRoyce Pearson Date: Thu, 30 Apr 2020 19:54:40 -0600 Subject: [PATCH] Remove non-null assertion in `CacheHash.release()` People using the API as intended would never trigger this assertion anyway, but if someone has a non standard use case, I see no reason to make the program panic. --- lib/std/cache_hash.zig | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/std/cache_hash.zig b/lib/std/cache_hash.zig index 20d2323370..963614fa6b 100644 --- a/lib/std/cache_hash.zig +++ b/lib/std/cache_hash.zig @@ -349,14 +349,14 @@ pub const CacheHash = struct { /// Writing to the manifest file is the only way that this file can return an /// error. pub fn release(self: *@This()) !void { - debug.assert(self.manifest_file != null); + if (self.manifest_file) |file| { + if (self.manifest_dirty) { + try self.write_manifest(); + } - if (self.manifest_dirty) { - try self.write_manifest(); + file.close(); } - self.manifest_file.?.close(); - for (self.files.items) |*file| { file.deinit(self.alloc); }