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

Method prepare

packages/core/src/engine/engine.ts:171–195  ·  view source on GitHub ↗

* Initialization preparations * 1. Check if there are any missing versions, and supplement if there are any. * 2. Check whether there are unsynchronized changesets locally, and if so, perform necessary transforms to keep revision and snapshot aligned * 3. Each engine will be prepared when i

(checkVersion?: number)

Source from the content-addressed store, hash-verified

169 * checkVersion does not exist when instantiated
170 */
171 async prepare(checkVersion?: number) {
172 try {
173 await this.checkLocalDiffChanges(checkVersion);
174 this.prepared = true;
175 } catch (error) {
176 Player.doTrigger(Events.app_error_logger, {
177 error,
178 metaData: {
179 localPendingChangeset: this.bufferStorage.localPendingChangeset,
180 opBuffer: this.bufferStorage.opBuffer,
181 },
182 });
183
184 // clear the local cache to prevent the problem from happening again
185 this.bufferStorage.clearLocalPendingChangeset();
186 this.bufferStorage.clearOpBuffer();
187
188 this.event.onError && this.event.onError({
189 type: ErrorType.CollaError,
190 code: ErrorCode.EngineCreateFailed,
191 message: t(Strings.local_data_conflict),
192 modalType: ModalType.Info
193 });
194 }
195 }
196
197 /**
198 * Completed the version supplement of local resources, and can perform collaborative data synchronization operations

Callers 3

constructorMethod · 0.95
checkVersionMethod · 0.80
server.jsFile · 0.80

Calls 5

checkLocalDiffChangesMethod · 0.95
tFunction · 0.90
onErrorMethod · 0.65
clearOpBufferMethod · 0.45

Tested by

no test coverage detected