Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/Config.zig
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,13 @@ pub fn userAgentSuffix(self: *const Config) ?[]const u8 {
};
}

pub fn cacheDir(self: *const Config) ?[]const u8 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should have a default folder, something like $XDG_CACHE_DIR/lightpanda

return switch (self.mode) {
inline .serve, .fetch, .mcp => |opts| opts.common.cache_dir,
else => null,
};
}

pub fn cdpTimeout(self: *const Config) usize {
return switch (self.mode) {
.serve => |opts| if (opts.timeout > 604_800) 604_800_000 else @as(usize, opts.timeout) * 1000,
Expand Down Expand Up @@ -240,6 +247,7 @@ pub const Common = struct {
log_format: ?log.Format = null,
log_filter_scopes: ?[]log.Scope = null,
user_agent_suffix: ?[]const u8 = null,
cache_dir: ?[]const u8 = null,

web_bot_auth_key_file: ?[]const u8 = null,
web_bot_auth_keyid: ?[]const u8 = null,
Expand Down Expand Up @@ -907,5 +915,14 @@ fn parseCommonArg(
return true;
}

if (std.mem.eql(u8, "--cache_dir", opt)) {
const str = args.next() orelse {
log.fatal(.app, "missing argument value", .{ .arg = "--cache_dir" });
return error.InvalidArgument;
};
common.cache_dir = try allocator.dupe(u8, str);
return true;
}

return false;
}
16 changes: 8 additions & 8 deletions src/Notification.zig
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const lp = @import("lightpanda");

const log = @import("log.zig");
const Page = @import("browser/Page.zig");
const Transfer = @import("browser/HttpClient.zig").Transfer;
const LiveTransfer = @import("browser/HttpClient.zig").LiveTransfer;

const Allocator = std.mem.Allocator;

Expand Down Expand Up @@ -138,34 +138,34 @@ pub const PageFrameCreated = struct {
};

pub const RequestStart = struct {
transfer: *Transfer,
transfer: *LiveTransfer,
};

pub const RequestIntercept = struct {
transfer: *Transfer,
transfer: *LiveTransfer,
wait_for_interception: *bool,
};

pub const RequestAuthRequired = struct {
transfer: *Transfer,
transfer: *LiveTransfer,
wait_for_interception: *bool,
};

pub const ResponseData = struct {
data: []const u8,
transfer: *Transfer,
transfer: *LiveTransfer,
};

pub const ResponseHeaderDone = struct {
transfer: *Transfer,
transfer: *LiveTransfer,
};

pub const RequestDone = struct {
transfer: *Transfer,
transfer: *LiveTransfer,
};

pub const RequestFail = struct {
transfer: *Transfer,
transfer: *LiveTransfer,
err: anyerror,
};

Expand Down
Loading
Loading