MCPcopy Create free account
hub / github.com/codedogQBY/ReadAny / emitProgress

Function emitProgress

packages/core/src/sync/sync-files.ts:255–279  ·  view source on GitHub ↗
(currentBytes?: number, totalBytes?: number)

Source from the content-addressed store, hash-verified

253 const tasksWithProgress = tasks.map((task, index) => async () => {
254 const fileNumber = index + 1;
255 const emitProgress = (currentBytes?: number, totalBytes?: number) => {
256 if (isPositiveFiniteNumber(totalBytes)) {
257 taskTotalBytes.set(index, totalBytes);
258 }
259 if (currentBytes !== undefined) {
260 const knownTotal = taskTotalBytes.get(index);
261 const boundedBytes = knownTotal
262 ? Math.max(0, Math.min(currentBytes, knownTotal))
263 : Math.max(0, currentBytes);
264 taskLoadedBytes.set(index, boundedBytes);
265 }
266 const totalTransferBytes = getTotalTransferBytes();
267 onProgress?.({
268 phase: "files",
269 operation,
270 currentFile: task.label,
271 completedFiles: completed,
272 totalFiles: total,
273 ...(currentBytes !== undefined ? { currentBytes } : {}),
274 ...(totalBytes !== undefined ? { totalBytes } : {}),
275 ...(taskLoadedBytes.size > 0 ? { totalCurrentBytes: getTotalCurrentBytes() } : {}),
276 ...(totalTransferBytes !== undefined ? { totalTransferBytes } : {}),
277 message: `${operationLabel} file ${fileNumber}/${total}...`,
278 });
279 };
280
281 emitProgress();
282 const result = await task.run((loaded, taskTotal) => {

Callers 1

runFileTasksFunction · 0.85

Calls 4

isPositiveFiniteNumberFunction · 0.85
getTotalTransferBytesFunction · 0.85
getTotalCurrentBytesFunction · 0.85
getMethod · 0.65

Tested by

no test coverage detected