Skip to content

Commit

Permalink
show cache dir
Browse files Browse the repository at this point in the history
  • Loading branch information
donpdonp committed Jan 9, 2025
1 parent 0653118 commit af6ffa4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
13 changes: 6 additions & 7 deletions src/db/file.zig
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
const std = @import("std");
const builtin = @import("builtin");
const warn = std.debug.print;
const util = @import("../util.zig");
const warn = util.log;
const Allocator = std.mem.Allocator;

const cache_dir = "./cache";

pub fn init() !void {
pub fn init(alloc: Allocator) !void {
const realpath = std.fs.Dir.realpathAlloc(std.fs.cwd(), alloc, cache_dir) catch unreachable;
std.posix.mkdir(cache_dir, 0o644) catch |err| {
if (err != error.PathAlreadyExists) return err;
warn("cache dir {s}", .{realpath});
};
}

pub fn has(namespace: []const u8, key: []const u8, allocator: Allocator) bool {
_ = cache_dir;
_ = namespace;
_ = key;
_ = allocator;
const keypath = "Z"; //std.fmt.allocPrint(allocator, "{s}/{s}/{s}", .{ cache_dir, namespace, key }) catch unreachable;
const keypath = std.fmt.allocPrint(allocator, "{s}/{s}/{s}", .{ cache_dir, namespace, key }) catch unreachable;
var found = false;
if (std.fs.cwd().access(keypath, .{ .mode = .read_only })) {
found = true;
Expand Down
2 changes: 1 addition & 1 deletion src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ fn initialize(allocator: std.mem.Allocator) !void {
try heartbeat.init(allocator);
try statemachine.init(allocator);
try db.init(allocator);
try dbfile.init();
try dbfile.init(allocator);
}

fn statewalk(allocator: std.mem.Allocator) void {
Expand Down

0 comments on commit af6ffa4

Please sign in to comment.