Re-opening the db should not unload formatter functions

This commit is contained in:
Kovid Goyal 2016-09-13 16:06:26 +05:30
parent 5c366c0201
commit bd0a2129b1

View File

@ -1031,17 +1031,18 @@ class DB(object):
data = self.custom_field_metadata(label, num) data = self.custom_field_metadata(label, num)
self.execute('UPDATE custom_columns SET mark_for_delete=1 WHERE id=?', (data['num'],)) self.execute('UPDATE custom_columns SET mark_for_delete=1 WHERE id=?', (data['num'],))
def close(self, force=False): def close(self, force=False, unload_formatter_functions=True):
if getattr(self, '_conn', None) is not None: if getattr(self, '_conn', None) is not None:
try: if unload_formatter_functions:
unload_user_template_functions(self.library_id) try:
except Exception: unload_user_template_functions(self.library_id)
pass except Exception:
pass
self._conn.close(force) self._conn.close(force)
del self._conn del self._conn
def reopen(self, force=False): def reopen(self, force=False):
self.close(force) self.close(force=force, unload_formatter_functions=False)
self._conn = None self._conn = None
self.conn self.conn
@ -1070,7 +1071,7 @@ class DB(object):
shell.process_command('.read ' + fname.replace(os.sep, '/')) shell.process_command('.read ' + fname.replace(os.sep, '/'))
conn.execute('PRAGMA user_version=%d;'%uv) conn.execute('PRAGMA user_version=%d;'%uv)
self.close() self.close(unload_formatter_functions=False)
try: try:
atomic_rename(tmpdb, self.dbpath) atomic_rename(tmpdb, self.dbpath)
finally: finally: