MCPcopy Create free account
hub / github.com/GCWing/BitFun / doRefresh

Method doRefresh

src/web-ui/src/tools/git/state/GitStateManager.ts:371–514  ·  view source on GitHub ↗

* Execute an actual refresh.

(
    repositoryPath: string,
    layers: GitStateLayer[],
    force: boolean,
    reason: RefreshReason,
    silent: boolean,
    source?: string
  )

Source from the content-addressed store, hash-verified

369 * Execute an actual refresh.
370 */
371 private async doRefresh(
372 repositoryPath: string,
373 layers: GitStateLayer[],
374 force: boolean,
375 reason: RefreshReason,
376 silent: boolean,
377 source?: string
378 ): Promise<void> {
379 const existingLock = this.refreshLocks.get(repositoryPath);
380 if (existingLock) {
381 if (!force) {
382 await existingLock;
383 return;
384 }
385 try {
386 await existingLock;
387 } catch {
388 // A force refresh after a failed in-flight refresh should still get a
389 // chance to rebuild fresh state.
390 }
391 }
392
393 const startedAt = nowMs();
394 const shouldProbeReason =
395 reason === 'window-focus' || reason === 'visibility' || reason === 'mount';
396 let probeError: string | null = null;
397 let probeOutcome = 'completed';
398
399 let state = this.getOrCreateState(repositoryPath);
400 const prevState = { ...state };
401
402
403 const now = Date.now();
404 const layersToRefresh = force
405 ? layers
406 : layers.filter((layer) => this.isCacheExpired(state, layer, now));
407
408 if (layersToRefresh.length === 0) {
409 if (shouldProbeReason) {
410 sendDebugProbe('GitStateManager.ts:doRefresh', 'Git refresh skipped by cache', {
411 repositoryPath,
412 reason,
413 force,
414 silent,
415 requestedLayers: layers,
416 });
417 }
418 return;
419 }
420
421 log.debug('Starting refresh', { repositoryPath, layersToRefresh, reason });
422
423 const refreshPromise = (async () => {
424 try {
425
426 if (!silent) {
427 state = this.updateState(repositoryPath, {
428 isRefreshing: true,

Callers 1

executePendingRefreshMethod · 0.95

Calls 15

getOrCreateStateMethod · 0.95
isCacheExpiredMethod · 0.95
updateStateMethod · 0.95
refreshBasicAndStatusMethod · 0.95
refreshDetailedMethod · 0.95
getStateMethod · 0.95
notifySubscribersMethod · 0.95
emitStateChangedMethod · 0.95
nowMsFunction · 0.90
sendDebugProbeFunction · 0.90
compareStatesFunction · 0.90
elapsedMsFunction · 0.90

Tested by

no test coverage detected