diff --git a/src/location/GeoIp.zig b/src/location/GeoIp.zig index accaddf..ded42ef 100644 --- a/src/location/GeoIp.zig +++ b/src/location/GeoIp.zig @@ -48,7 +48,6 @@ pub fn deinit(self: *GeoIP) void { c.MMDB_close(self.mmdb); self.allocator.destroy(self.mmdb); self.ip2location_client.deinit(); - log.debug("destroying client", .{}); self.allocator.destroy(self.ip2location_client); } diff --git a/src/location/Ip2location.zig b/src/location/Ip2location.zig index 32df3db..3968866 100644 --- a/src/location/Ip2location.zig +++ b/src/location/Ip2location.zig @@ -198,6 +198,11 @@ pub const Cache = struct { if (lines.next()) |first_line| { if (!std.mem.eql(u8, first_line, "#Ip2location:v2")) { log.warn("Cache file missing or invalid header, discarding", .{}); + file.close(); + self.file = null; + std.fs.deleteFileAbsolute(self.path) catch |e| { + log.err("error deleting {s}: {}", .{ self.path, e }); + }; return; } } else {