Ensure refs are unique on export
In general, we do not enforce that ref is unique in a library. However, when exporting to various formats, we should ensure that all the documents have a unique ref.
This should apply to
- [ ] BibTeX
- [ ] Typst / Hayagriva
xref https://github.com/papis/papis/discussions/935
Hmm this is somewhat related to #988, #1038
Should we make export error out on:
- having many docs with same ref key
- appending duplicates
?
Should we make
exporterror out on:
I'm not sure what a good behavior would be here, since you can always delete/rename them after the fact if you need them to be unique. From what I can tell:
- You can export things to use them in a TeX documents, which will complain about duplicates.
- You can export things just to have a backup, in which case duplicate refs don't matter that much.
So maybe a warning would be appropriate?
This also raises the issue of what to do on --append, since ensuring no duplicates means we need to read the existing file in, check it, possibly fix it, append the new documents, and write it back out.
Could we leverage papis doctor functionality for this? Maybe this could be enabled by setting auto-doctor to true or with a --auto-doctor flag (though in this case it would just check the refs?).
Somewhat relatedly, I think we might eventually want to have auto-doctor default to true