mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 20:45:00 -05:00
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.
19 lines
659 B
JavaScript
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;
|
|
}
|
|
}
|