Remove redundant DB commit on delete.

This commit is contained in:
Arun Prakash Jana 2016-11-28 22:10:01 +05:30
parent 82551c5706
commit 46f2f5a1bd

10
buku.py
View File

@ -939,9 +939,7 @@ class BukuDb:
try: try:
query = 'DELETE from bookmarks where id BETWEEN ? AND ?' query = 'DELETE from bookmarks where id BETWEEN ? AND ?'
self.cur.execute(query, (low, high)) self.cur.execute(query, (low, high))
if not delay_commit: print('Bookmarks from index %d to %d deleted' % (low, high))
self.conn.commit()
print('Bookmarks from index %s to %s deleted' % (low, high))
# Compact DB by ascending order of index to ensure # Compact DB by ascending order of index to ensure
# the existing higher indices move only once # the existing higher indices move only once
@ -960,11 +958,11 @@ class BukuDb:
try: try:
query = 'DELETE FROM bookmarks WHERE id = ?' query = 'DELETE FROM bookmarks WHERE id = ?'
self.cur.execute(query, (index,)) self.cur.execute(query, (index,))
if not delay_commit:
self.conn.commit()
if self.cur.rowcount == 1: if self.cur.rowcount == 1:
print('Removed index %d' % index) print('Removed index %d' % index)
self.compactdb(index, delay_commit) self.compactdb(index, delay_commit=True)
if not delay_commit:
self.conn.commit()
else: else:
logerr('No matching index') logerr('No matching index')
return False return False