Do not insert new tag if already present.
Signed-off-by: Arun Prakash Jana <engineerarun@gmail.com>
This commit is contained in:
parent
5d8ac94fcd
commit
017f7b82cd
14
buku
14
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()
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user