8555: Database repair tool always modify all source objects
This commit is contained in:
parent
da018c1842
commit
79cb66b0f1
@ -1962,6 +1962,7 @@ class CheckIntegrity:
|
|||||||
self.progress.step()
|
self.progress.step()
|
||||||
source = self.db.get_source_from_handle(handle)
|
source = self.db.get_source_from_handle(handle)
|
||||||
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 = []
|
||||||
@ -1984,6 +1985,7 @@ class CheckIntegrity:
|
|||||||
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))
|
||||||
@ -1994,8 +1996,9 @@ class CheckIntegrity:
|
|||||||
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)
|
||||||
|
|
||||||
source.set_media_list(new_media_ref_list)
|
if citation_changed:
|
||||||
self.db.commit_source(source, self.trans)
|
source.set_media_list(new_media_ref_list)
|
||||||
|
self.db.commit_source(source, self.trans)
|
||||||
|
|
||||||
if len(self.replaced_sourceref) > 0:
|
if len(self.replaced_sourceref) > 0:
|
||||||
logging.info(' OK: no broken source citations on mediarefs '
|
logging.info(' OK: no broken source citations on mediarefs '
|
||||||
|
Loading…
Reference in New Issue
Block a user