Compare commits
No commits in common. "796259ceb67263aaec9f6c501c495d03ca682f45" and "945b8d23f7dcee7f69f2cdfb4e4486c4d3d84c5b" have entirely different histories.
796259ceb6
...
945b8d23f7
1 changed files with 4 additions and 12 deletions
16
src/root.zig
16
src/root.zig
|
@ -289,19 +289,11 @@ pub const NotmuchDb = struct {
|
||||||
///
|
///
|
||||||
/// Error: Returns error if database cannot be opened or path cannot be resolved
|
/// 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 {
|
pub fn openNotmuchDb(allocator: std.mem.Allocator, relative_path: []const u8, email_engine: ?Email) !NotmuchDb {
|
||||||
const db_path = if (std.fs.path.isAbsolute(relative_path))
|
var cwd_buf: [std.fs.max_path_bytes]u8 = undefined;
|
||||||
try allocator.dupeZ(u8, relative_path)
|
const cwd = try std.fs.cwd().realpath(".", cwd_buf[0..]);
|
||||||
else blk: {
|
const db_path = try std.fs.path.joinZ(allocator, &[_][]const u8{ cwd, relative_path });
|
||||||
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| {
|
const db = try notmuch.Db.open(db_path, null);
|
||||||
std.log.err("Could not open {s}", .{db_path});
|
|
||||||
return err;
|
|
||||||
};
|
|
||||||
|
|
||||||
const email = email_engine orelse Email.init();
|
const email = email_engine orelse Email.init();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue