Fix #5779 (Check database integrity is broken in 0.7 w/custom fields)

This commit is contained in:
Kovid Goyal 2010-06-10 22:44:08 -06:00
parent 3d2811a24b
commit efe64efe25
3 changed files with 15 additions and 1 deletions

View File

@ -609,7 +609,8 @@ class TagBrowserMixin(object): # {{{
self.tags_view.saved_search_edit.connect(self.do_saved_search_edit)
self.tags_view.tag_item_renamed.connect(self.do_tag_item_renamed)
self.tags_view.search_item_renamed.connect(self.saved_search.clear_to_help)
self.edit_categories.clicked.connect(self.do_user_categories_edit)
self.edit_categories.clicked.connect(lambda x:
self.do_user_categories_edit())
def do_user_categories_edit(self, on_category=None):
d = TagCategories(self, self.library_view.model().db, on_category)

View File

@ -1842,6 +1842,8 @@ books_series_link feeds
os.remove(self.dbpath)
shutil.copyfile(dest, self.dbpath)
self.connect()
self.field_metadata.remove_dynamic_categories()
self.field_metadata.remove_custom_fields()
self.initialize_dynamic()
self.refresh()
if os.path.exists(dest):

View File

@ -379,6 +379,17 @@ class FieldMetadata(dict):
self._add_search_terms_to_map(key, [key])
self.custom_label_to_key_map[label] = key
def remove_custom_fields(self):
for key in self.get_custom_fields():
del self._tb_cats[key]
def remove_dynamic_categories(self):
for key in list(self._tb_cats.keys()):
val = self._tb_cats[key]
if val['is_category'] and val['kind'] in ('user', 'search'):
del self._tb_cats[key]
def add_user_category(self, label, name):
if label in self._tb_cats:
raise ValueError('Duplicate user field [%s]'%(label))