From 51e2a8a1e1c729fa2ece25689fed09dc5e1daa7c Mon Sep 17 00:00:00 2001 From: jim Date: Thu, 7 May 2026 15:49:35 -0500 Subject: [PATCH] fix: stop infinite loop when reply text is a literal dot '.' was used as a sentinel for 'not yet fetched' in the SELECT query, but it is also valid reply text. This caused any post where a reply text was literally '.' to stay in the work queue forever. Also fixes the fan-out UPDATE guard: previously it used IFNULL(replyText, '.') <> @newValue, which would overwrite '?' (confirmed-empty) rows with '.' when processing a dot reply elsewhere in the reblog chain, pulling completed posts back into the queue and causing the remaining counter to increase. Changes: - Remove OR replyText = '.' from GetRepliesWithFilledText SELECT - Restrict UpdateNoteReplyText fan-out to NULL/'' rows only - Use '?' not '.' as null-coalesce fallback in UpdateNoteReplyText Co-Authored-By: Claude Sonnet 4.6 --- URLNotesGrabberCORE/DataAccess.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/URLNotesGrabberCORE/DataAccess.cs b/URLNotesGrabberCORE/DataAccess.cs index 3ae316d..d8bf849 100644 --- a/URLNotesGrabberCORE/DataAccess.cs +++ b/URLNotesGrabberCORE/DataAccess.cs @@ -873,7 +873,7 @@ namespace URLNotesGrabberCORE INNER JOIN Notes N ON N.PostID = P.PostID AND N.RootBlogName = P.BlogName WHERE P.NotFound = 0 AND N.type = 'reply' - AND (N.replyText IS NULL OR N.replyText = '' OR N.replyText = '.') + AND (N.replyText IS NULL OR N.replyText = '') GROUP BY P.BlogName, P.PostID ORDER BY LatestTimestamp ASC"; @@ -1479,10 +1479,10 @@ namespace URLNotesGrabberCORE //string sql = "UPDATE Notes SET replyText = @replyText WHERE rootBlogName = @rootBlogName AND PostID = @PostID AND noteBlogName = @noteBlogName AND TimeStamp = @TimeStamp AND Type = 'reply'"; // Match on (noteBlogName, TimeStamp ±5s) only - a reply by a given blog at a given timestamp is the same reply across the original post and every reblog of it, so this fans out across reblog chains in one shot. Tolerance absorbs the ~1s drift between what -collect stored and what mode=conversation returns now. - string sql = "UPDATE Notes SET replyText = @replyText, DateModified = @dateModified WHERE noteBlogName = @noteBlogName AND ABS(TimeStamp - @TimeStamp) <= 5 AND Type = 'reply' AND IFNULL(replyText, '.') <> @replyText"; + string sql = "UPDATE Notes SET replyText = @replyText, DateModified = @dateModified WHERE noteBlogName = @noteBlogName AND ABS(TimeStamp - @TimeStamp) <= 5 AND Type = 'reply' AND (replyText IS NULL OR replyText = '')"; using (SQLiteCommand command = new SQLiteCommand(sql, connection)) { - command.Parameters.AddWithValue("@replyText", replyText ?? "."); + command.Parameters.AddWithValue("@replyText", replyText ?? "?"); command.Parameters.AddWithValue("@dateModified", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); command.Parameters.AddWithValue("@rootBlogName", rootBlogName); command.Parameters.AddWithValue("@PostID", postID);