From 4205c7b8a1deb8fc088b38e399ac08dd11e05c6f Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Tue, 19 Jun 2012 17:46:02 +0200 Subject: [PATCH] Do a commit when preferences are restored. Ensure that the in-memory copy of the prefs is correct after restore. --- src/calibre/library/prefs.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/calibre/library/prefs.py b/src/calibre/library/prefs.py index 4bd39e20b2..1b80464d2a 100644 --- a/src/calibre/library/prefs.py +++ b/src/calibre/library/prefs.py @@ -84,13 +84,15 @@ class DBPrefs(dict): try: from_filename = os.path.join(library_path, 'metadata_db_prefs.json') with open(from_filename, "rb") as f: + self.clear() d = json.load(f, object_hook=from_json) self.db.conn.execute('DELETE FROM preferences') for k,v in d.iteritems(): raw = self.to_raw(v) self.db.conn.execute( - 'INSERT OR REPLACE INTO preferences (key,val) VALUES (?,?)', - (k, raw)) + 'INSERT INTO preferences (key,val) VALUES (?,?)', (k, raw)) + self.db.conn.commit() + self.update(d) except: import traceback traceback.print_exc() \ No newline at end of file