From 34203d73ddeb1348ef558933e9b2be3c3f2ee9c9 Mon Sep 17 00:00:00 2001 From: "Grant T. Olson" Date: Sat, 7 Sep 2013 13:31:17 -0400 Subject: [PATCH] Only UPDATE readStatus if it changed --- src/bitmessagemain.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/bitmessagemain.py b/src/bitmessagemain.py index a5a4b320..9f976c67 100755 --- a/src/bitmessagemain.py +++ b/src/bitmessagemain.py @@ -414,7 +414,10 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler): readStatus = params[1] if not isinstance(readStatus, bool): raise APIError(23, 'Bool expected in readStatus, saw %s instead.' % type(readStatus)) - sqlExecute('''UPDATE inbox set read = ? WHERE msgid=?''', readStatus, msgid) + queryreturn = sqlQuery('''SELECT read FROM inbox WHERE msgid=?''', msgid) + # UPDATE is slow, only update if status is different + if queryreturn != [] and (queryreturn[0][0] == 1) != readStatus: + sqlExecute('''UPDATE inbox set read = ? WHERE msgid=?''', readStatus, msgid) queryreturn = sqlQuery('''SELECT msgid, toaddress, fromaddress, subject, received, message, encodingtype, read FROM inbox WHERE msgid=?''', msgid) data = '{"inboxMessage":[' for row in queryreturn: