From 1433a58b6a87dbfbb48eac7c09128f01fbb6712c Mon Sep 17 00:00:00 2001 From: Arun Prakash Jana Date: Fri, 22 Apr 2016 20:10:58 +0530 Subject: [PATCH] Optimize full DB refresh. --- buku | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/buku b/buku index eb3652e..c82f254 100755 --- a/buku +++ b/buku @@ -456,8 +456,8 @@ def dbRefresh(conn, cur, index): cur.execute("SELECT id, url FROM bookmarks WHERE id = ?", (index,)) resultset = cur.fetchall() - for row in resultset: - if titleManual is None: + if titleManual is None: + for row in resultset: title = fetchTitle(row[1]) if title == '': print("\x1B[91mTitle: []") @@ -465,15 +465,20 @@ def dbRefresh(conn, cur, index): continue else: print("Title: [%s]" % title) - else: - if titleManual == "none": - title = '' - else: - title = titleManual - cur.execute("UPDATE bookmarks SET metadata = ? WHERE id = ?", (title, row[0],)) - conn.commit() - print("Updated index %d\n" % row[0]) + cur.execute("UPDATE bookmarks SET metadata = ? WHERE id = ?", (title, row[0],)) + conn.commit() + print("Updated index %d\n" % row[0]) + else: + if titleManual == "none": + title = '' + else: + title = titleManual + + for row in resultset: + cur.execute("UPDATE bookmarks SET metadata = ? WHERE id = ?", (title, row[0],)) + conn.commit() + print("Updated index %d\n" % row[0])