8555: Database repair tool always modify all source objects

This commit is contained in:
romjerome 2016-11-26 12:51:56 +01:00
parent e81c82fcc0
commit 1c241125d7

View File

@ -1949,6 +1949,7 @@ class CheckIntegrity(object):
source = Source() source = Source()
source.unserialize(info) source.unserialize(info)
new_media_ref_list = [] new_media_ref_list = []
citation_changed = False
for media_ref in source.get_media_list(): for media_ref in source.get_media_list():
citation_list = media_ref.get_citation_list() citation_list = media_ref.get_citation_list()
new_citation_list = [] new_citation_list = []
@ -1971,6 +1972,7 @@ class CheckIntegrity(object):
citation_handle = create_id() citation_handle = create_id()
new_citation.set_handle(citation_handle) new_citation.set_handle(citation_handle)
self.replaced_sourceref.append(handle) self.replaced_sourceref.append(handle)
citation_changed = True
logging.warning(' FAIL: the source "%s" has a media ' logging.warning(' FAIL: the source "%s" has a media '
'reference with a source citation ' 'reference with a source citation '
'which is invalid' % (source.gramps_id)) 'which is invalid' % (source.gramps_id))
@ -1981,6 +1983,7 @@ class CheckIntegrity(object):
media_ref.set_citation_list(new_citation_list) media_ref.set_citation_list(new_citation_list)
new_media_ref_list.append(media_ref) new_media_ref_list.append(media_ref)
if citation_changed:
source.set_media_list(new_media_ref_list) source.set_media_list(new_media_ref_list)
self.db.commit_source(source, self.trans) self.db.commit_source(source, self.trans)