Lightpanda: the headless browser designed for AI and automation
make indexedb in-memory only (for now)
Karl Seguinb0bccbb4bcbb
diff --git a/src/Config.zig b/src/Config.zigindex 957fde542..293a7f2db 100644--- a/src/Config.zig+++ b/src/Config.zig@@ -85,6 +85,7 @@ fn logLevelValidator(_: Allocator, args: *std.process.ArgIterator) !?log.Level {}/// Common CLI args.+<<<<<<< HEADconst CommonOptions = .{.{ .name = "obey_robots", .type = bool },.{ .name = "proxy_bearer_token", .type = ?[:0]const u8 },@@ -116,7 +117,6 @@ const CommonOptions = .{.{ .name = "enable_external_stylesheets", .type = bool },.{ .name = "v8_flags_unsafe", .type = ?[]const u8 },.{ .name = "v8_max_heap_mb", .type = ?u32 },- .{ .name = "indexdb_dir", .type = ?[:0]const u8 },};fn dumpValidator(_: Allocator, args: *std.process.ArgIterator) !?DumpFormat {@@ -584,13 +584,6 @@ pub fn storageSqlitePath(self: *const Config) ?[:0]const u8 {};}-pub fn indexDBDir(self: *const Config) ?[:0]const u8 {- return switch (self.mode) {- inline .serve, .fetch, .mcp, .agent => |opts| opts.indexdb_dir,- else => unreachable,- };-}-pub const DumpFormat = enum {html,markdown,diff --git a/src/browser/Session.zig b/src/browser/Session.zigindex 228bc9c77..d40915645 100644--- a/src/browser/Session.zig+++ b/src/browser/Session.zig@@ -162,7 +162,7 @@ pub fn init(self: *Session, browser: *Browser, notification: *Notification) !voi// The prototype (EventTarget) for Navigation is created when a Frame is created..navigation = .{ ._proto = undefined },.storage_shed = .{},- .idb = IdbManager.init(allocator, browser.app.config.indexDBDir()),+ .idb = IdbManager.init(allocator),.browser = browser,.notification = notification,.cookie_jar = storage.Cookie.Jar.init(allocator, notification),diff --git a/src/browser/webapi/storage/idb/Manager.zig b/src/browser/webapi/storage/idb/Manager.zigindex c69a33037..0803dfe26 100644--- a/src/browser/webapi/storage/idb/Manager.zig+++ b/src/browser/webapi/storage/idb/Manager.zig@@ -27,11 +27,10 @@ const Allocator = std.mem.Allocator;const Manager = @This();allocator: Allocator,-base_dir: []const u8,engines: std.StringHashMapUnmanaged(*Engine) = .empty,-pub fn init(allocator: Allocator, base_dir: ?[]const u8) Manager {- return .{ .allocator = allocator, .base_dir = base_dir orelse ":memory:" };+pub fn init(allocator: Allocator) Manager {+ return .{ .allocator = allocator };}pub fn deinit(self: *Manager) void {@@ -55,7 +54,7 @@ pub fn engineForOrigin(self: *Manager, origin: []const u8) !*Engine {const engine = try self.allocator.create(Engine);errdefer self.allocator.destroy(engine);- engine.* = try self.open(origin);+ engine.* = try Engine.open(":memory:");errdefer engine.close();gop.key_ptr.* = try self.allocator.dupe(u8, origin);@@ -63,29 +62,9 @@ pub fn engineForOrigin(self: *Manager, origin: []const u8) !*Engine {return engine;}-fn open(self: *Manager, origin: []const u8) !Engine {- if (std.mem.eql(u8, self.base_dir, ":memory:")) {- return Engine.open(":memory:");- }-- // we hash the origin for two reason:- // 1 - it fixes the length, so we don't have to worry about illegally long filename- // 2 - It removes any unsafe characters- var digest: [16]u8 = undefined;- std.crypto.hash.Blake3.hash(origin, &digest, .{});- var name_buf: [64]u8 = undefined;- const file_name = std.fmt.bufPrint(&name_buf, "idb-{x}.sqlite", .{&digest}) catch unreachable;-- const path = try std.fs.path.joinZ(self.allocator, &.{ self.base_dir, file_name });- defer self.allocator.free(path);-- log.debug(.storage, "idb open", .{ .origin = origin, .path = path });- return Engine.open(path);-}-const testing = @import("../../../../testing.zig");test "IDB - Manager: same origin returns same engine, distinct origins differ" {- var mgr = Manager.init(testing.allocator, null);+ var mgr = Manager.init(testing.allocator);defer mgr.deinit();const a1 = try mgr.engineForOrigin("https://a.com");@@ -97,7 +76,7 @@ test "IDB - Manager: same origin returns same engine, distinct origins differ" {}test "IDB - Manager: in-memory engines are origin-isolated" {- var mgr = Manager.init(testing.allocator, null);+ var mgr = Manager.init(testing.allocator);defer mgr.deinit();const a = try mgr.engineForOrigin("https://a.com");@@ -108,12 +87,7 @@ test "IDB - Manager: in-memory engines are origin-isolated" {}test "IDB - Manager: on-disk engines hash to per-origin files, isolated" {- var tmp = std.testing.tmpDir(.{});- defer tmp.cleanup();- const dir = try tmp.dir.realpathAlloc(testing.allocator, ".");- defer testing.allocator.free(dir);-- var mgr = Manager.init(testing.allocator, dir);+ var mgr = Manager.init(testing.allocator);defer mgr.deinit();// A long origin (hostname near the 253-byte limit) must still open: the