From 756a0a3f82c32548ca7f3c77297de999b1fe6f92 Mon Sep 17 00:00:00 2001 From: Timothy Legge Date: Fri, 9 Jul 2010 16:36:40 -0300 Subject: [PATCH] Actually delete from the database even if an image is not found --- src/calibre/devices/kobo/driver.py | 31 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/calibre/devices/kobo/driver.py b/src/calibre/devices/kobo/driver.py index 131775e66a..f4c4cad3c7 100644 --- a/src/calibre/devices/kobo/driver.py +++ b/src/calibre/devices/kobo/driver.py @@ -176,23 +176,22 @@ class KOBO(USBMS): ImageID = row[0] cursor.close() + cursor = connection.cursor() + if ContentType == 6: + # Delete the shortcover_pages first + cursor.execute('delete from shortcover_page where shortcoverid in (select ContentID from content where BookID = ?)', t) + + #Delete the volume_shortcovers second + cursor.execute('delete from volume_shortcovers where volumeid = ?', t) + + # Delete the chapters associated with the book next + t = (ContentID,ContentID,) + cursor.execute('delete from content where BookID = ? or ContentID = ?', t) + + connection.commit() + + cursor.close() if ImageID != None: - cursor = connection.cursor() - if ContentType == 6: - # Delete the shortcover_pages first - cursor.execute('delete from shortcover_page where shortcoverid in (select ContentID from content where BookID = ?)', t) - - #Delete the volume_shortcovers second - cursor.execute('delete from volume_shortcovers where volumeid = ?', t) - - # Delete the chapters associated with the book next - t = (ContentID,ContentID,) - cursor.execute('delete from content where BookID = ? or ContentID = ?', t) - - connection.commit() - - cursor.close() - else: print "Error condition ImageID was not found" print "You likely tried to delete a book that the kobo has not yet added to the database"