diff --git a/src/caosadvancedtools/cfoods/h5.py b/src/caosadvancedtools/cfoods/h5.py index cbf9d0baefa435b71eeaeefe63a9b018faabe7ea..2a29f9fbe3175f9757e051b43e801503cc39dd1e 100644 --- a/src/caosadvancedtools/cfoods/h5.py +++ b/src/caosadvancedtools/cfoods/h5.py @@ -172,6 +172,20 @@ class H5CFood(AbstractFileCFood): self.to_be_inserted = db.Container() self.insert_missing_structure(self.structure) + for el in self.to_be_inserted: + if isinstance(el, db.File): + el.retrieve() + + valids = [] + + for el in self.to_be_inserted: + if el.is_valid(): + valids.append(el.id) + + for el in self.to_be_inserted: + if el.id is not None and el.id in valids: + self.to_be_inserted.remove(el) + # TODO this is a workaround due to the fact that the caosdb library # changes the objects in the Container if it is inserted. The graph # structure is flattened. I.e. references to other entity objects are