This commit is contained in:
mitteneer 2025-07-14 18:04:46 -04:00
parent b0f7884f84
commit 2a42e07df0
2 changed files with 3 additions and 3 deletions

View file

@ -111,7 +111,6 @@ pub fn post(request: *jetzig.Request) !jetzig.View {
try album_hash_string.appendSlice(artist);
const artist_hash = std.hash.Fnv1a_64.hash(artist);
try stored_artist_hashes.append(artist_hash);
//const signed_hash_string = try std.fmt.allocPrint(request.allocator, "{}", .{@as(i64, @bitCast(artist_hash))});
const signed_hash_string = try std.fmt.bufPrint(&hash_buffer, "{}", .{@as(i64, @bitCast(artist_hash))});
if (artists.get(signed_hash_string) == null) try artists.put(signed_hash_string, artist);
}
@ -123,7 +122,6 @@ pub fn post(request: *jetzig.Request) !jetzig.View {
for (stored_artist_hashes.items) |artist_hash| {
const artistalbum_hash = pair(artist_hash, album_hash);
//const signed_artistalbums_hash_string = try std.fmt.allocPrint(request.allocator, "{}", .{@as(i64, @bitCast(artistalbum_hash))});
const signed_artistalbums_hash_string = try std.fmt.bufPrint(&hash_buffer, "{}", .{@as(i64, @bitCast(artistalbum_hash))});
if (tracks.get(signed_artistalbums_hash_string) == null) {
var artistalbum = try artistalbums.put(signed_artistalbums_hash_string, .object);
@ -132,6 +130,8 @@ pub fn post(request: *jetzig.Request) !jetzig.View {
}
}
// The track hash does not currently include the track artists. Probably not necessary for it to,
// but easily can if need be
var track_hash_string = std.ArrayList(u8).init(request.allocator);
try track_hash_string.appendSlice(complete_scrobble.album);
try track_hash_string.appendSlice(complete_scrobble.track);

View file

@ -74,7 +74,7 @@ pub fn loadRules(allocator: std.mem.Allocator) !?[]Data.Rule {
});
defer rule_file.close();
const rule_file_size = try rule_file.stat().size;
const rule_file_size = (try rule_file.stat()).size;
const rule_file_content = try rule_file.readToEndAlloc(allocator, rule_file_size);
return std.json.parseFromSliceLeaky([]Data.Rule, allocator, rule_file_content, .{}) catch null;
}