Skip to content

Commit

Permalink
fix: avoid citation key collision
Browse files Browse the repository at this point in the history
  • Loading branch information
AllanChain committed May 18, 2024
1 parent c4c2e90 commit 7a3626e
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/modules/arxiv-merge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,22 @@ export class arXivMerge {
// @ts-ignore some fields are not listed in zotero-type
journalJSON[field] = preprintJSON[field];
});
/* Avoid citation key collision after preprint item updates (say year)
* For example, no collision:
* - Published item: li_wang_2024-1
* - Preprint item: li_wang_2024
* Thing will work without problem.
* Collision:
* - Published item: li_wang_2024
* - Preprint item: li_wang_2023
* If we do nothing, after `preprintItem.saveTx`, the citation key will update
* to li_wang_2024-1, which is something we don't want. One approach is to fix
* the citation key for the preprint item. But it involves working with BBT.
* The workaround here is to set a random citation key for the published item.
* TODO: What if the user wants to keep the citation key (not fixed in BBT)?
*/
publishedItem.setField("extra", `Citation Key: ${crypto.randomUUID()}`);
publishedItem.saveTx();
preprintItem.fromJSON(journalJSON);
preprintItem.saveTx();
if (getPref("mergePreferJournalPDF")) {
Expand Down

0 comments on commit 7a3626e

Please sign in to comment.