delete cache if old
This commit is contained in:
parent
bfae3c726b
commit
a79094efdc
2 changed files with 5 additions and 1 deletions
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue