artefactual-labs / mets-reader-writer

Library to parse and create METS files, especially for Archivematica.
https://mets-reader-writer.readthedocs.io
GNU Affero General Public License v3.0
20 stars 13 forks source link

Fix duplicates when mixing explicit and autogenerated ids #70

Closed cole closed 5 years ago

cole commented 5 years ago

When some metadata section ids, but not all, are autogenerated, duplicates can easily occur. This PR changes metsrw to track ids used, and if a conflicting id is generated, retry.

I'm not totally happy with this implementation, I think if we had a more consistent metadata class structure, we could easily do this in a base class, but it's an improvement on what was there.

I've also made id_string a property (vs a method) in bdf84b6, which is a small API change that will require updates to a few lines in Archivematica (all in archivematicaCreateMETSReingest.py). That change can be dropped if it is problematic, it just seemed like an easy improvement.

Connects to https://github.com/archivematica/Issues/issues/442.

cole commented 5 years ago

Works in my testing when combined with the changes in https://github.com/artefactual/archivematica/pull/1407