From cf8e81e26862b463c6d42fc6359557db85eb8d90 Mon Sep 17 00:00:00 2001 From: fiaxh Date: Sun, 7 Jun 2026 23:10:29 +0200 Subject: Handle invalid content item database entries better --- libdino/src/service/content_item_store.vala | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'libdino') diff --git a/libdino/src/service/content_item_store.vala b/libdino/src/service/content_item_store.vala index 99475492..37c82eb7 100644 --- a/libdino/src/service/content_item_store.vala +++ b/libdino/src/service/content_item_store.vala @@ -44,8 +44,8 @@ public class ContentItemStore : StreamInteractionModule, Object { Gee.TreeSet items = new Gee.TreeSet(ContentItem.compare_func); foreach (var row in select) { - ContentItem content_item = get_item_from_row(row, conversation); - items.add(content_item); + ContentItem? content_item = get_item_from_row(row, conversation); + if (content_item != null) items.add(content_item); } Gee.List ret = new ArrayList(); @@ -55,7 +55,7 @@ public class ContentItemStore : StreamInteractionModule, Object { return ret; } - private ContentItem get_item_from_row(Row row, Conversation conversation) throws Error { + private ContentItem? get_item_from_row(Row row, Conversation conversation) { int id = row[db.content_item.id]; int content_type = row[db.content_item.content_type]; int foreign_id = row[db.content_item.foreign_id]; @@ -63,7 +63,7 @@ public class ContentItemStore : StreamInteractionModule, Object { return get_item(conversation, id, content_type, foreign_id, time); } - private ContentItem get_item(Conversation conversation, int id, int content_type, int foreign_id, DateTime time) throws Error { + private ContentItem? get_item(Conversation conversation, int id, int content_type, int foreign_id, DateTime time) { switch (content_type) { case 1: Message? message = stream_interactor.get_module(MessageStorage.IDENTITY).get_message_by_id(foreign_id, conversation); @@ -95,7 +95,8 @@ public class ContentItemStore : StreamInteractionModule, Object { warning("Unknown content item type: %i", content_type); break; } - throw new Error(-1, 0, "Bad content type %i or non existing content item %i", content_type, foreign_id); + warning("Bad content type %i or non existing content item %i", content_type, foreign_id); + return null; } public ContentItem? get_item_by_foreign(Conversation conversation, int type, int foreign_id) { -- cgit v1.3