From 12271efe3dcbc330311a20d22f8f41cb153afa71 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 15 Feb 2015 11:28:40 +0530 Subject: [PATCH] Do not write to the db when storing preferences that have not actually changed --- src/calibre/db/backend.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/calibre/db/backend.py b/src/calibre/db/backend.py index 890a77c9e5..baae1e96a5 100644 --- a/src/calibre/db/backend.py +++ b/src/calibre/db/backend.py @@ -106,11 +106,10 @@ class DBPrefs(dict): # {{{ self.db.execute('DELETE FROM preferences WHERE key=?', (key,)) def __setitem__(self, key, val): - if self.disable_setting: - return - raw = self.to_raw(val) - self.db.execute('INSERT OR REPLACE INTO preferences (key,val) VALUES (?,?)', (key, raw)) - dict.__setitem__(self, key, val) + if not self.disable_setting and val != self[key]: + raw = self.to_raw(val) + self.db.execute('INSERT OR REPLACE INTO preferences (key,val) VALUES (?,?)', (key, raw)) + dict.__setitem__(self, key, val) def set(self, key, val): self.__setitem__(key, val)