mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #6850 (KOBO: Editing the Im_Reading list with SD Card installed)
This commit is contained in:
commit
12dbfa2e18
@ -424,7 +424,7 @@ class KOBO(USBMS):
|
|||||||
paths[source_id] = os.path.join(prefix, *(path.split('/')))
|
paths[source_id] = os.path.join(prefix, *(path.split('/')))
|
||||||
return paths
|
return paths
|
||||||
|
|
||||||
def update_device_database_collections(self, booklists, collections_attributes):
|
def update_device_database_collections(self, booklists, collections_attributes, oncard):
|
||||||
# debug_print('Starting update_device_database_collections', collections_attributes)
|
# debug_print('Starting update_device_database_collections', collections_attributes)
|
||||||
|
|
||||||
# Force collections_attributes to be 'tags' as no other is currently supported
|
# Force collections_attributes to be 'tags' as no other is currently supported
|
||||||
@ -433,14 +433,20 @@ class KOBO(USBMS):
|
|||||||
|
|
||||||
collections = booklists.get_collections(collections_attributes)
|
collections = booklists.get_collections(collections_attributes)
|
||||||
# debug_print('Collections', collections)
|
# debug_print('Collections', collections)
|
||||||
for category, books in collections.items():
|
|
||||||
if category == 'Im_Reading':
|
|
||||||
# Create a connection to the sqlite database
|
# Create a connection to the sqlite database
|
||||||
|
# Needs to be outside books collection as in the case of removing
|
||||||
|
# the last book from the collection the list of books is empty
|
||||||
|
# and the removal of the last book would not occur
|
||||||
connection = sqlite.connect(self._main_prefix + '.kobo/KoboReader.sqlite')
|
connection = sqlite.connect(self._main_prefix + '.kobo/KoboReader.sqlite')
|
||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
|
|
||||||
# Reset Im_Reading list in the database
|
# Reset Im_Reading list in the database
|
||||||
query= 'update content set ReadStatus=0, FirstTimeReading = \'true\' where BookID is Null'
|
if oncard == 'carda':
|
||||||
|
query= 'update content set ReadStatus=0, FirstTimeReading = \'true\' where BookID is Null and ContentID like \'file:///mnt/sd/%\''
|
||||||
|
elif oncard != 'carda' and oncard != 'cardb':
|
||||||
|
query= 'update content set ReadStatus=0, FirstTimeReading = \'true\' where BookID is Null and ContentID not like \'file:///mnt/sd/%\''
|
||||||
|
|
||||||
try:
|
try:
|
||||||
cursor.execute (query)
|
cursor.execute (query)
|
||||||
except:
|
except:
|
||||||
@ -450,6 +456,8 @@ class KOBO(USBMS):
|
|||||||
# debug_print('Commit: Reset Im_Reading list')
|
# debug_print('Commit: Reset Im_Reading list')
|
||||||
connection.commit()
|
connection.commit()
|
||||||
|
|
||||||
|
for category, books in collections.items():
|
||||||
|
if category == 'Im_Reading':
|
||||||
for book in books:
|
for book in books:
|
||||||
# debug_print('Title:', book.title, 'lpath:', book.path)
|
# debug_print('Title:', book.title, 'lpath:', book.path)
|
||||||
book.device_collections = ['Im_Reading']
|
book.device_collections = ['Im_Reading']
|
||||||
@ -494,12 +502,16 @@ class KOBO(USBMS):
|
|||||||
|
|
||||||
#debug_print('KOBO: collection fields:', collections)
|
#debug_print('KOBO: collection fields:', collections)
|
||||||
for i, blist in blists.items():
|
for i, blist in blists.items():
|
||||||
self.update_device_database_collections(blist, collections)
|
if i == 0:
|
||||||
|
oncard = 'main'
|
||||||
|
else:
|
||||||
|
oncard = 'carda'
|
||||||
|
self.update_device_database_collections(blist, collections, oncard)
|
||||||
|
|
||||||
USBMS.sync_booklists(self, booklists, end_session=end_session)
|
USBMS.sync_booklists(self, booklists, end_session=end_session)
|
||||||
#debug_print('KOBO: finished sync_booklists')
|
#debug_print('KOBO: finished sync_booklists')
|
||||||
|
|
||||||
def rebuild_collections(self, booklist, oncard):
|
def rebuild_collections(self, booklist, oncard):
|
||||||
collections_attributes = []
|
collections_attributes = []
|
||||||
self.update_device_database_collections(booklist, collections_attributes)
|
self.update_device_database_collections(booklist, collections_attributes, oncard)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user