mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Dont call __setitem__ while holding db connection open
This commit is contained in:
parent
4d992eaa69
commit
13259a4c9c
@ -120,6 +120,7 @@ class DBPrefs(dict): # {{{
|
||||
def __setitem__(self, key, val):
|
||||
if not self.disable_setting:
|
||||
raw = self.to_raw(val)
|
||||
do_set = False
|
||||
with self.db.conn:
|
||||
try:
|
||||
dbraw = next(self.db.execute('SELECT id,val FROM preferences WHERE key=?', (key,)))
|
||||
@ -130,7 +131,9 @@ class DBPrefs(dict): # {{{
|
||||
self.db.execute('INSERT INTO preferences (key,val) VALUES (?,?)', (key, raw))
|
||||
else:
|
||||
self.db.execute('UPDATE preferences SET val=? WHERE id=?', (raw, dbraw[0]))
|
||||
dict.__setitem__(self, key, val)
|
||||
do_set = True
|
||||
if do_set:
|
||||
dict.__setitem__(self, key, val)
|
||||
|
||||
def set(self, key, val):
|
||||
self.__setitem__(key, val)
|
||||
|
Loading…
x
Reference in New Issue
Block a user