diff --git a/src/db/Remote.zig b/src/db/Remote.zig index 632d3fa..2f0039e 100644 --- a/src/db/Remote.zig +++ b/src/db/Remote.zig @@ -119,7 +119,7 @@ fn apiRequest(self: Remote, alloc: std.mem.Allocator, user: ?User, endpoint: str defer headers.deinit(); if (user) |_| { - if (_handler.getAccessToken(try user.?.uuid.toString(alloc))) |token| { + if (_handler.getAccessToken(&user.?.uuid.bytes())) |token| { switch (self.type) { .github => try headers.appendValue("Authorization", try std.mem.join(alloc, " ", &.{ "Bearer", token })), .gitea => try headers.appendValue("Authorization", try std.mem.join(alloc, " ", &.{ "token", token })), @@ -206,7 +206,7 @@ fn apiPost(self: Remote, alloc: std.mem.Allocator, user: ?User, endpoint: string defer headers.deinit(); if (user) |_| { - if (_handler.getAccessToken(try user.?.uuid.toString(alloc))) |token| { + if (_handler.getAccessToken(&user.?.uuid.bytes())) |token| { try headers.appendValue("Authorization", try std.mem.join(alloc, " ", &.{ "Bearer", token })); } } diff --git a/src/db/Version.zig b/src/db/Version.zig index 4e7fc5c..0a0e8f1 100644 --- a/src/db/Version.zig +++ b/src/db/Version.zig @@ -74,7 +74,7 @@ pub fn format(self: Version, comptime fmt: string, options: std.fmt.FormatOption } pub fn setVersion(self: *Version, alloc: std.mem.Allocator, approver: User, major: u32, minor: u32) !void { - try self.update(alloc, .approved_by, try approver.uuid.toString(alloc)); + try self.update(alloc, .approved_by, &approver.uuid.bytes()); try self.update(alloc, .real_major, major); try self.update(alloc, .real_minor, minor); } diff --git a/src/handler/_handler.zig b/src/handler/_handler.zig index 3cf11f2..8981fae 100644 --- a/src/handler/_handler.zig +++ b/src/handler/_handler.zig @@ -111,7 +111,7 @@ pub fn saveInfo(response: *http.Response, request: http.Request, idp: oauth2.Pro const alloc = request.arena; const r = (try db.Remote.byKey(alloc, .domain, idp.domain())) orelse unreachable; const u = (try r.findUserBy(alloc, .snowflake, id)) orelse try db.User.create(alloc, r.id, id, name); - const ulid = try _internal.access_tokens.allocator.dupe(u8, try u.uuid.toString(alloc)); + const ulid = try _internal.access_tokens.allocator.dupe(u8, &u.uuid.bytes()); try response.headers.put("Set-Cookie", try std.fmt.allocPrint(alloc, "jwt={s}", .{ try ox.token.encodeMessage(alloc, ulid), diff --git a/src/handler/do_import.zig b/src/handler/do_import.zig index f26692d..0c3dc5f 100644 --- a/src/handler/do_import.zig +++ b/src/handler/do_import.zig @@ -88,7 +88,7 @@ pub fn get(_: void, response: *http.Response, request: http.Request, captures: ? const tarfile = try std.fs.cwd().openFile(tarpath, .{}); defer tarfile.close(); - const destdirpath = try std.fs.path.join(alloc, &.{ root.datadirpath, "packages", try u.uuid.toString(alloc), details.id }); + const destdirpath = try std.fs.path.join(alloc, &.{ root.datadirpath, "packages", &u.uuid.bytes(), details.id }); try std.fs.cwd().makePath(destdirpath); const destpath = try std.fs.path.join(alloc, &.{ destdirpath, try std.mem.concat(alloc, u8, &.{ "latest", ".tar.gz" }) }); diff --git a/src/handler/hook.zig b/src/handler/hook.zig index 888451e..3e29a72 100644 --- a/src/handler/hook.zig +++ b/src/handler/hook.zig @@ -119,9 +119,8 @@ pub fn post(_: void, response: *http.Response, request: http.Request, captures: try std.fs.cwd().deleteTree(path); - // TODO remove toString usages const jobs = [_]string{ - try (try db.Job.create(alloc, p, commit, .x86_64, .debian)).uuid.toString(alloc), + &(try db.Job.create(alloc, p, commit, .x86_64, .debian)).uuid.bytes(), }; var v = try db.Version.create(alloc, p, commit, unpackedsize, totalsize, filelist, tarsize, tarhash, deps, rootdeps, builddeps, readme, &jobs); diff --git a/zigmod.lock b/zigmod.lock index 8ff3f4c..c66ff30 100644 --- a/zigmod.lock +++ b/zigmod.lock @@ -30,7 +30,7 @@ git https://github.com/kivikakk/zunicode commit-5bf4a3a5f0c6e3d96f6def56957ab7f2 git https://github.com/nektro/ox commit-ee7d31a66d82ed86b4610eea66cb0b8c7c420995 git https://github.com/nektro/zig-zorm commit-e5176e73203424da95a9d660648016d6f3776281 git https://github.com/vrischmann/zig-sqlite commit-13b8e4e6a036f43d28a5f6691587ca1d8baa7eae -git https://github.com/nektro/zig-ulid commit-d2834174ee6a0011ee42fe43be2886c539a146ce +git https://github.com/nektro/zig-ulid commit-7f2c7edf0e7f91229be17bda52d0e74d42d862e2 git https://github.com/leroycep/zig-jwt commit-137598749184c830ad07d9e5762b9db5e9a326c6 git https://gist.github.com/nektro/a0045048d8e7458e42520e9ffb90becd commit-3fdb9fddeefa8ebb2c60a3b349fff4e635993cea git https://gist.github.com/nektro/64c7da67a00d8b94091d754dd2cf1aa9 commit-4d6ac0b23bd3e55c1907eeced651fca04721a88d