From 017f7b82cdc9272d374a1c1aa9145f46104da29e Mon Sep 17 00:00:00 2001 From: Arun Prakash Jana Date: Sat, 19 Mar 2016 22:36:44 +0530 Subject: [PATCH] Do not insert new tag if already present. Signed-off-by: Arun Prakash Jana --- buku | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/buku b/buku index 215b71b..0d34d06 100755 --- a/buku +++ b/buku @@ -406,10 +406,14 @@ def showUniqueTags(cur): # Replace or delete tags in DB def replaceTags(conn, cur, orig, new): + update = False + delete = False + orig = ',' + orig + ',' new = new.strip(',') if new == '': new = ',' + delete = True else: new = ',' + new + ',' @@ -417,11 +421,17 @@ def replaceTags(conn, cur, orig, new): results = cur.fetchall() for row in results: - print("Updating index %d" % row[0]) + if delete == False: + if row[1].find(new) >= 0: + new = ',' + newtags = row[1].replace(orig, new) cur.execute("UPDATE bookmarks SET tags = ? WHERE id = ?", (newtags, row[0],)) + print("Updated index %d" % row[0]) + update = True - conn.commit() + if update: + conn.commit()