From 796259ceb67263aaec9f6c501c495d03ca682f45 Mon Sep 17 00:00:00 2001 From: Emil Lerch Date: Wed, 15 Oct 2025 19:27:59 -0700 Subject: [PATCH] handle absolute paths in openNotmuchDb --- src/root.zig | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/root.zig b/src/root.zig index 88761e3..489952d 100644 --- a/src/root.zig +++ b/src/root.zig @@ -289,9 +289,13 @@ pub const NotmuchDb = struct { /// /// Error: Returns error if database cannot be opened or path cannot be resolved pub fn openNotmuchDb(allocator: std.mem.Allocator, relative_path: []const u8, email_engine: ?Email) !NotmuchDb { - var cwd_buf: [std.fs.max_path_bytes]u8 = undefined; - const cwd = try std.fs.cwd().realpath(".", cwd_buf[0..]); - const db_path = try std.fs.path.joinZ(allocator, &[_][]const u8{ cwd, relative_path }); + const db_path = if (std.fs.path.isAbsolute(relative_path)) + try allocator.dupeZ(u8, relative_path) + else blk: { + var cwd_buf: [std.fs.max_path_bytes]u8 = undefined; + const cwd = try std.fs.cwd().realpath(".", cwd_buf[0..]); + break :blk try std.fs.path.joinZ(allocator, &[_][]const u8{ cwd, relative_path }); + }; errdefer allocator.free(db_path); const db = notmuch.Db.open(db_path, null) catch |err| {