mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix bug that caused error message when automatically sending news to device, if the news had been previously deleted
This commit is contained in:
parent
e48113d5a7
commit
9f5bf522bd
@ -755,6 +755,7 @@ class Main(MainWindow, Ui_MainWindow):
|
|||||||
def sync_news(self):
|
def sync_news(self):
|
||||||
if self.device_connected:
|
if self.device_connected:
|
||||||
ids = list(dynamic.get('news_to_be_synced', set([])))
|
ids = list(dynamic.get('news_to_be_synced', set([])))
|
||||||
|
ids = [id for id in ids if self.library_view.model().db.has_id(id)]
|
||||||
files = [self.library_view.model().db.format(id, prefs['output_format'], index_is_id=True, as_file=True) for id in ids]
|
files = [self.library_view.model().db.format(id, prefs['output_format'], index_is_id=True, as_file=True) for id in ids]
|
||||||
files = [f for f in files if f is not None]
|
files = [f for f in files if f is not None]
|
||||||
metadata = self.library_view.model().get_metadata(ids, rows_are_ids=True)
|
metadata = self.library_view.model().get_metadata(ids, rows_are_ids=True)
|
||||||
@ -889,6 +890,7 @@ class Main(MainWindow, Ui_MainWindow):
|
|||||||
self.job_exception(job)
|
self.job_exception(job)
|
||||||
return
|
return
|
||||||
id = self.library_view.model().add_news(pt.name, recipe)
|
id = self.library_view.model().add_news(pt.name, recipe)
|
||||||
|
self.library_view.model().reset()
|
||||||
sync = dynamic.get('news_to_be_synced', set([]))
|
sync = dynamic.get('news_to_be_synced', set([]))
|
||||||
sync.add(id)
|
sync.add(id)
|
||||||
dynamic.set('news_to_be_synced', sync)
|
dynamic.set('news_to_be_synced', sync)
|
||||||
|
@ -232,6 +232,9 @@ class ResultCache(SearchQueryParser):
|
|||||||
def row(self, id):
|
def row(self, id):
|
||||||
return self.index(id)
|
return self.index(id)
|
||||||
|
|
||||||
|
def has_id(self, id):
|
||||||
|
return self._data[id] is not None
|
||||||
|
|
||||||
def refresh_ids(self, conn, ids):
|
def refresh_ids(self, conn, ids):
|
||||||
for id in ids:
|
for id in ids:
|
||||||
self._data[id] = conn.get('SELECT * from meta WHERE id=?', (id,))[0]
|
self._data[id] = conn.get('SELECT * from meta WHERE id=?', (id,))[0]
|
||||||
@ -371,6 +374,7 @@ class LibraryDatabase2(LibraryDatabase):
|
|||||||
self.index = self.data.index
|
self.index = self.data.index
|
||||||
self.refresh_ids = functools.partial(self.data.refresh_ids, self.conn)
|
self.refresh_ids = functools.partial(self.data.refresh_ids, self.conn)
|
||||||
self.row = self.data.row
|
self.row = self.data.row
|
||||||
|
self.has_id = self.data.has_id
|
||||||
|
|
||||||
self.refresh()
|
self.refresh()
|
||||||
|
|
||||||
@ -589,7 +593,7 @@ class LibraryDatabase2(LibraryDatabase):
|
|||||||
data = data.read()
|
data = data.read()
|
||||||
p.loadFromData(data)
|
p.loadFromData(data)
|
||||||
p.save(path)
|
p.save(path)
|
||||||
|
|
||||||
def all_formats(self):
|
def all_formats(self):
|
||||||
formats = self.conn.get('SELECT format from data')
|
formats = self.conn.get('SELECT format from data')
|
||||||
if not formats:
|
if not formats:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user