diff --git a/src/location/GeoLite2.zig b/src/location/GeoLite2.zig index 12983c4..69d9587 100644 --- a/src/location/GeoLite2.zig +++ b/src/location/GeoLite2.zig @@ -30,6 +30,11 @@ fn downloadDatabase(allocator: std.mem.Allocator, path: []const u8) !void { if (result.status != .ok) return error.DownloadFailed; + // Ensure directory exists + if (std.fs.path.dirname(path)) |dir| { + try std.fs.cwd().makePath(dir); + } + const file = try std.fs.cwd().createFile(path, .{}); defer file.close(); try file.writeAll(response_buf[0..writer.end]);