Skip to content
Merged
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
2 changes: 1 addition & 1 deletion src/app.zig
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ fn getAndMakeAppDir(allocator: Allocator) ?[]const u8 {
return null;
};

std.fs.makeDirAbsolute(app_dir_path) catch |err| switch (err) {
std.fs.cwd().makePath(app_dir_path) catch |err| switch (err) {
error.PathAlreadyExists => return app_dir_path,
else => {
allocator.free(app_dir_path);
Expand Down
10 changes: 9 additions & 1 deletion src/telemetry/telemetry.zig
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ fn TelemetryT(comptime P: type) type {
}

fn getOrCreateId(app_dir_path_: ?[]const u8) ?[36]u8 {
const app_dir_path = app_dir_path_ orelse return null;
const app_dir_path = app_dir_path_ orelse {
var id: [36]u8 = undefined;
uuidv4(&id);
return id;
};

var buf: [37]u8 = undefined;
var dir = std.fs.openDirAbsolute(app_dir_path, .{}) catch |err| {
Expand Down Expand Up @@ -146,6 +150,10 @@ test "telemetry: getOrCreateId" {
std.fs.cwd().deleteFile("/tmp/" ++ IID_FILE) catch {};
const id3 = getOrCreateId("/tmp/").?;
try testing.expectEqual(false, std.mem.eql(u8, &id1, &id3));

const id4 = getOrCreateId(null).?;
try testing.expectEqual(false, std.mem.eql(u8, &id1, &id4));
try testing.expectEqual(false, std.mem.eql(u8, &id3, &id4));
}

test "telemetry: sends event to provider" {
Expand Down