File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ fn getAndMakeAppDir(allocator: Allocator) ?[]const u8 {
6767 return null ;
6868 };
6969
70- std .fs .makeDirAbsolute (app_dir_path ) catch | err | switch (err ) {
70+ std .fs .cwd (). makePath (app_dir_path ) catch | err | switch (err ) {
7171 error .PathAlreadyExists = > return app_dir_path ,
7272 else = > {
7373 allocator .free (app_dir_path );
Original file line number Diff line number Diff line change @@ -60,7 +60,11 @@ fn TelemetryT(comptime P: type) type {
6060}
6161
6262fn getOrCreateId (app_dir_path_ : ? []const u8 ) ? [36 ]u8 {
63- const app_dir_path = app_dir_path_ orelse return null ;
63+ const app_dir_path = app_dir_path_ orelse {
64+ var id : [36 ]u8 = undefined ;
65+ uuidv4 (& id );
66+ return id ;
67+ };
6468
6569 var buf : [37 ]u8 = undefined ;
6670 var dir = std .fs .openDirAbsolute (app_dir_path , .{}) catch | err | {
@@ -146,6 +150,10 @@ test "telemetry: getOrCreateId" {
146150 std .fs .cwd ().deleteFile ("/tmp/" ++ IID_FILE ) catch {};
147151 const id3 = getOrCreateId ("/tmp/" ).? ;
148152 try testing .expectEqual (false , std .mem .eql (u8 , & id1 , & id3 ));
153+
154+ const id4 = getOrCreateId (null ).? ;
155+ try testing .expectEqual (false , std .mem .eql (u8 , & id1 , & id4 ));
156+ try testing .expectEqual (false , std .mem .eql (u8 , & id3 , & id4 ));
149157}
150158
151159test "telemetry: sends event to provider" {
You can’t perform that action at this time.
0 commit comments