Files
wekan/server/lib/listSyncCardId.js
T
Lauri Ojansivu 38e8716e59 Prevent duplicate Sync card creation across concurrent runs
Use a stable database ID for new list/source/issue mappings. Stop on creation conflicts without replacing moved cards or claiming successful reconciliation. Cover concurrent database writers, browser clients, moved-card recovery and unrelated database failures.

Thanks to xet7.
2026-09-27 21:57:42 +03:00

13 lines
504 B
JavaScript

const { createHash } = require('node:crypto');
// Keep a retry (including another worker) on the same database primary key.
// JSON tuple encoding avoids delimiter collisions in external IDs. Use the
// entire digest; this ID is an identity, never an authorization credential.
function listSyncCardId(listId, sourceKey, externalId) {
return `sync-${createHash('sha256')
.update(JSON.stringify([listId, sourceKey, String(externalId)]))
.digest('hex')}`;
}
module.exports = { listSyncCardId };