fix: possible fix for rare forceingest error
When a typed relation is sent to the graveyard, it gets an invalid type
to ensure it won't be used. Sometimes, when merging agents with many
relations, forceingest trips over its own shoelaces. Do some caching and
redundant setting to try to avoid that.
@@ -135,15 +135,16 @@ class HackyMerger:
return
for loser in losers:
- for identifier in loser.identifiers.all():
+ for identifier in list(loser.identifiers.all()):
identifier.administrative_change(agent=winner)
- for rel in loser.work_relations.all():
+ for rel in list(loser.work_relations.all()):
try:
rel.administrative_change(agent=winner)
except IntegrityError:
# OK, to the graveyard instead
rel.administrative_change(
+ agent=loser,
creative_work=self.graveyard,
type=''.join(random.sample(string.ascii_letters, 5))
)
