mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 18:54:09 -04:00
Tabs
This commit is contained in:
parent
f8369e741a
commit
2fa9fb85d1
@ -268,42 +268,42 @@ class PRST1(USBMS):
|
||||
collections = booklist.get_collections(collections_attributes)
|
||||
|
||||
with closing(sqlite.connect(dbpath)) as connection:
|
||||
self.remove_orphaned_records(connection, dbpath)
|
||||
self.remove_orphaned_records(connection, dbpath)
|
||||
self.update_device_books(connection, booklist, source_id,
|
||||
plugboard, dbpath)
|
||||
self.update_device_collections(connection, booklist, collections, source_id, dbpath)
|
||||
|
||||
debug_print('PRST1: finished update_device_database')
|
||||
|
||||
def remove_orphaned_records(self, connection, dbpath):
|
||||
from sqlite3 import DatabaseError
|
||||
def remove_orphaned_records(self, connection, dbpath):
|
||||
from sqlite3 import DatabaseError
|
||||
|
||||
try:
|
||||
cursor = connection.cursor()
|
||||
|
||||
debug_print("Removing Orphaned Collection Records")
|
||||
|
||||
# Purge any collections references that point into the abyss
|
||||
query = 'DELETE FROM collections WHERE content_id NOT IN (SELECT _id FROM books)'
|
||||
cursor.execute(query)
|
||||
query = 'DELETE FROM collections WHERE collection_id NOT IN (SELECT _id FROM collection)'
|
||||
cursor.execute(query)
|
||||
|
||||
debug_print("Removing Orphaned Book Records")
|
||||
|
||||
# Purge any references to books not in this database
|
||||
# Idea is to prevent any spill-over where these wind up applying to some other book
|
||||
query = 'DELETE FROM %s WHERE content_id NOT IN (SELECT _id FROM books)'
|
||||
cursor.execute(query%'annotation')
|
||||
cursor.execute(query%'bookmark')
|
||||
cursor.execute(query%'current_position')
|
||||
cursor.execute(query%'freehand')
|
||||
cursor.execute(query%'history')
|
||||
cursor.execute(query%'layout_cache')
|
||||
cursor.execute(query%'preference')
|
||||
|
||||
cursor.close()
|
||||
except DatabaseError:
|
||||
cursor = connection.cursor()
|
||||
|
||||
debug_print("Removing Orphaned Collection Records")
|
||||
|
||||
# Purge any collections references that point into the abyss
|
||||
query = 'DELETE FROM collections WHERE content_id NOT IN (SELECT _id FROM books)'
|
||||
cursor.execute(query)
|
||||
query = 'DELETE FROM collections WHERE collection_id NOT IN (SELECT _id FROM collection)'
|
||||
cursor.execute(query)
|
||||
|
||||
debug_print("Removing Orphaned Book Records")
|
||||
|
||||
# Purge any references to books not in this database
|
||||
# Idea is to prevent any spill-over where these wind up applying to some other book
|
||||
query = 'DELETE FROM %s WHERE content_id NOT IN (SELECT _id FROM books)'
|
||||
cursor.execute(query%'annotation')
|
||||
cursor.execute(query%'bookmark')
|
||||
cursor.execute(query%'current_position')
|
||||
cursor.execute(query%'freehand')
|
||||
cursor.execute(query%'history')
|
||||
cursor.execute(query%'layout_cache')
|
||||
cursor.execute(query%'preference')
|
||||
|
||||
cursor.close()
|
||||
except DatabaseError:
|
||||
import traceback
|
||||
tb = traceback.format_exc()
|
||||
raise DeviceError((('The SONY database is corrupted. '
|
||||
|
Loading…
x
Reference in New Issue
Block a user