From e199c00cc9f67040231ae31f694abb89e3780118 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 29 Sep 2010 18:08:05 -0600 Subject: [PATCH] Initialize dirtied_cache correctly --- src/calibre/library/database2.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/calibre/library/database2.py b/src/calibre/library/database2.py index ca8824ae1c..9d9ebf64c5 100644 --- a/src/calibre/library/database2.py +++ b/src/calibre/library/database2.py @@ -348,10 +348,10 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns): setattr(self, 'title_sort', functools.partial(self.get_property, loc=self.FIELD_MAP['sort'])) - self.dirtied_cache = set() d = self.conn.get('SELECT book FROM metadata_dirtied', all=True) for x in d: self.dirtied_queue.put(x[0]) + self.dirtied_cache = set([x[0] for x in d]) self.refresh_ondevice = functools.partial(self.data.refresh_ondevice, self) self.refresh() @@ -616,9 +616,7 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns): self.conn.commit() def dirtied(self, book_ids, commit=True): - for book in book_ids: - if book in self.dirtied_cache: - continue + for book in frozenset(book_ids) - self.dirtied_cache: try: self.conn.execute( 'INSERT INTO metadata_dirtied (book) VALUES (?)',