Files
wekan/server/lib/listSyncLease.js
T
Lauri Ojansivu 4d8ce77544 Coordinate Sync runs and settings saves with renewable list reservations
Share a private database reservation across scheduled Sync, manual Sync and configuration methods. Renew during fetches, verify ownership before writes, reclaim expired reservations and preserve replacement owners during cleanup. Document the remaining in-flight write fencing and multi-document recovery requirements.

Thanks to xet7.
2026-09-27 22:03:34 +03:00

19 lines
659 B
JavaScript

import { Meteor } from 'meteor/meteor';
import { Mongo } from 'meteor/mongo';
const { withSyncLease } = require('/server/lib/syncLease');
// Private coordination records contain no provider URLs or credentials.
const leases = new Mongo.Collection('listSyncLeases');
leases.deny({ insert: () => true, update: () => true, remove: () => true });
export async function withListSyncLease(listId, work) {
try {
return await withSyncLease(leases.rawCollection(), listId, work);
} catch (error) {
if (error.code === 'sync-busy' || error.code === 'sync-lease-lost') {
throw new Meteor.Error(error.code, error.message);
}
throw error;
}
}