MCPcopy Create free account
hub / github.com/apitable/apitable / checkVersion

Method checkVersion

packages/core/src/sync/room.ts:351–387  ·  view source on GitHub ↗
(resourceRevisions: IResourceRevision[] | null)

Source from the content-addressed store, hash-verified

349
350 @errorCapture<RoomService>()
351 async checkVersion(resourceRevisions: IResourceRevision[] | null) {
352 const missVersionEngines: { collaEngine: Engine; revision: number }[] = [];
353
354 if (!resourceRevisions || !resourceRevisions.length) {
355 console.log('The current resource has not been operated for a long time, and the data is automatically updated');
356 await this.collaEngineMap.get(this.roomId)?.event.reloadResourceData();
357 return;
358 }
359
360 for (const { resourceId, revision } of resourceRevisions) {
361 const collaEngine = this.collaEngineMap.get(resourceId);
362
363 if (!collaEngine) {
364 continue;
365 }
366
367 const baseRevision = collaEngine.getRevision();
368 const versionDiffs = numbersBetween(baseRevision, revision + 1);
369 if (!versionDiffs.length) {
370 continue;
371 }
372 if (versionDiffs.length >= 100) {
373 throw new EnhanceError({
374 code: StatusCode.FRONT_VERSION_ERROR,
375 message: t(Strings.changeset_diff_big_tip),
376 modalType: ModalType.Info,
377 });
378 }
379 missVersionEngines.push({ collaEngine, revision });
380 }
381
382 return await Promise.all(
383 missVersionEngines.map<Promise<any>>(({ collaEngine, revision }) => {
384 return collaEngine.prepare(revision + 1);
385 })
386 );
387 }
388
389 /**
390 * @description unwatch no longer needs to pay attention to whether the coordinator queue is emptied,

Callers 1

watchMethod · 0.95

Calls 9

numbersBetweenFunction · 0.90
tFunction · 0.90
reloadResourceDataMethod · 0.80
prepareMethod · 0.80
getMethod · 0.65
logMethod · 0.45
getRevisionMethod · 0.45
pushMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected