From 05cc7aa3f119ea6053d253ac7111bba40b0cf4d3 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 28 Feb 2011 08:19:16 -0700 Subject: [PATCH 1/3] Performance improvement when updating db prefs --- src/calibre/library/prefs.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/calibre/library/prefs.py b/src/calibre/library/prefs.py index 233c717897..4ef1dcb35a 100644 --- a/src/calibre/library/prefs.py +++ b/src/calibre/library/prefs.py @@ -49,8 +49,7 @@ class DBPrefs(dict): if self.disable_setting: return raw = self.to_raw(val) - self.db.conn.execute('DELETE FROM preferences WHERE key=?', (key,)) - self.db.conn.execute('INSERT INTO preferences (key,val) VALUES (?,?)', (key, + self.db.conn.execute('INSERT OR REPLACE INTO preferences (key,val) VALUES (?,?)', (key, raw)) self.db.conn.commit() dict.__setitem__(self, key, val) From 752d9f350da10cd7a8658f63c82b356dc360a52c Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 28 Feb 2011 08:43:39 -0700 Subject: [PATCH 2/3] Improve performance when cleaning user categories --- src/calibre/library/database2.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/calibre/library/database2.py b/src/calibre/library/database2.py index 8e90fe77bd..1762fd16d2 100644 --- a/src/calibre/library/database2.py +++ b/src/calibre/library/database2.py @@ -1196,7 +1196,8 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns): else: new_cats['.'.join(comps)] = user_cats[k] try: - self.prefs.set('user_categories', new_cats) + if new_cats != user_cats: + self.prefs.set('user_categories', new_cats) except: pass return new_cats From c2d85e81b772e54c7f946392ead78b4ed1c0b607 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 28 Feb 2011 08:45:31 -0700 Subject: [PATCH 3/3] MOBI Input: Ignore all ASCII control codes except CR, NL and Tab. Fixes #9219 (Instapaper magazine can't be shown in ebook-viewer) --- src/calibre/ebooks/mobi/reader.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/calibre/ebooks/mobi/reader.py b/src/calibre/ebooks/mobi/reader.py index 9c52a18691..f1b1b1ef63 100644 --- a/src/calibre/ebooks/mobi/reader.py +++ b/src/calibre/ebooks/mobi/reader.py @@ -18,6 +18,7 @@ from calibre import xml_entity_to_unicode, CurrentDir, entity_to_unicode, \ replace_entities from calibre.utils.filenames import ascii_filename from calibre.utils.date import parse_date +from calibre.utils.cleantext import clean_ascii_chars from calibre.ptempfile import TemporaryDirectory from calibre.ebooks import DRMError from calibre.ebooks.chardet import ENCODING_PATS @@ -323,6 +324,7 @@ class MobiReader(object): self.cleanup_html() self.log.debug('Parsing HTML...') + self.processed_html = clean_ascii_chars(self.processed_html) try: root = html.fromstring(self.processed_html) if len(root.xpath('//html')) > 5: