╭ changed ──────────╮ │src/event/Patch.zig│ ╰───────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭───────────────────────────────────────────────────────╮ │ 6 title: []const u8, │ │ 7 description: []const u8, │ │ 8 tags: []const u8, // space-separated │ │ 9 -target_ref: []const u8, │ │ 9 target_patch_id: ?[evt.event_id_size * 2]u8 = null,│ │11 -patchrev_id: [evt.event_id_size * 2]u8, │ │10 +patchrev_id: ?[evt.event_id_size * 2]u8 = null, │ │11 │ │12 pub const Record = struct { │ │13 event: Self, │ ╰───────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │63 break :blk value; │ │64 }; │ │65 │ │67 - if (!fieldsValid(record.event.title, record.event.tags) or record.event.target_ref.len == 0) { │ │68 - return error.InvalidPatch; │ │69 - } │ │70 - const patchrev_id = try evt.parseEventId(&record.event.patchrev_id); │ │66 + if (!fieldsValid(record.event.title, record.event.tags)) return error.InvalidPatch; │ │67 + if (record.event.patchrev_id) |*id| _ = try evt.parseEventId(id); │ │68 const target_patch_id = if (record.event.target_patch_id) |*id| try evt.parseEventId(id) else null;│ │69 if (target_patch_id) |*id| { │ │70 if (std.mem.eql(u8, id, event_id)) return error.InvalidPatch; │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ 83 } │ │ 84 } │ │ 85 │ │ 89 - if (event_oid != null) { │ │ 90 - const changed = if (existing_maybe) |existing| !std.mem.eql(u8, &existing.event.patchrev_id, &record.event.patchrev_id) else true; │ │ 91 - if (changed) { │ │ 92 - const patchrev = (try evt.PatchRev.readById(DB, hash_kind, haxy_moment.readOnly(), arena, &patchrev_id)) orelse return error.PatchRevNotFound; │ │ 93 - if (patchrev.removed) return error.PatchRevNotFound; │ │ 94 - if (target_patch_id) |*target_id| { │ │ 95 - const target = (try readById(DB, hash_kind, haxy_moment.readOnly(), arena, target_id)) orelse return error.TargetPatchNotFound; │ │ 96 - if (target.removed) return error.TargetPatchNotFound; │ │ 97 - const target_patchrev_id = try evt.parseEventId(&target.event.patchrev_id); │ │ 98 - const target_patchrev = (try evt.PatchRev.readById(DB, hash_kind, haxy_moment.readOnly(), arena, &target_patchrev_id)) orelse return error.PatchRevNotFound;│ │ 99 - if (target_patchrev.removed) return error.PatchRevNotFound; │ │100 - if (!std.mem.eql(u8, patchrev.event.base_oid, target_patchrev.patch_oid) or │ │101 - !std.mem.eql(u8, patchrev.base_tree_oid, target_patchrev.head_tree_oid)) │ │102 - { │ │103 - return error.InvalidPatchBase; │ │104 - } │ │105 - } │ │106 - } │ │107 - } │ │108 - │ │ 86 try evt.writeOid(Self, DB, hash_kind, field_oid_map, record_key, if (existing_maybe) |existing| existing.event else null, record.event, event_oid); │ │ 87 │ │ 88 const cursor = try records.putCursor(record_key); │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯