From 85b87553dd1afb3d354508025720a6003d6047af Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Fri, 7 Jul 2023 12:08:14 +0000 Subject: [PATCH] Avoid SQL logic error in blob replication. git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4340 ed5197a5-7fde-0310-b194-c3ffbd925b24 --- src/ssb.db.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ssb.db.c b/src/ssb.db.c index 8fc128ef..5b0c343e 100644 --- a/src/ssb.db.c +++ b/src/ssb.db.c @@ -174,13 +174,15 @@ void tf_ssb_db_init(tf_ssb_t* ssb) _tf_ssb_db_exec(db, "CREATE INDEX IF NOT EXISTS messages_refs_message_idx ON messages_refs (message)"); _tf_ssb_db_exec(db, "CREATE INDEX IF NOT EXISTS messages_refs_ref_idx ON messages_refs (ref)"); + _tf_ssb_db_exec(db, "DROP VIEW IF EXISTS blob_wants_view"); _tf_ssb_db_exec(db, "CREATE VIEW IF NOT EXISTS blob_wants_view (id) AS " " SELECT messages_refs.ref AS id " " FROM messages_refs " " LEFT OUTER JOIN blobs ON messages_refs.ref = blobs.id " - " WHERE messages_refs.ref LIKE '&____________________________________________.sha256' " - " AND blobs.id IS NULL"); + " WHERE blobs.id IS NULL " + " AND LENGTH(messages_refs.ref) = 52 " + " AND messages_refs.ref LIKE '&%.sha256'"); bool need_add_sequence_before_author = true; bool need_convert_timestamp_to_real = false;