MCPcopy Create free account
hub / github.com/error311/FileRise / estimateCryptoProgress

Function estimateCryptoProgress

public/js/folderManager.js:3024–3043  ·  view source on GitHub ↗
(totalBytes, doneBytes, elapsedMs)

Source from the content-addressed store, hash-verified

3022}
3023
3024function estimateCryptoProgress(totalBytes, doneBytes, elapsedMs) {
3025 if (!Number.isFinite(totalBytes) || totalBytes <= 0) return null;
3026
3027 let bps = readCryptoEstimateSpeed();
3028 if (Number.isFinite(doneBytes) && doneBytes > 0 && elapsedMs > 1000) {
3029 const observed = (doneBytes * 1000) / Math.max(1, elapsedMs);
3030 if (Number.isFinite(observed) && observed > 0) {
3031 bps = clampNum((bps * 0.45) + (observed * 0.55), CRYPTO_MIN_SPEED_BPS, CRYPTO_MAX_SPEED_BPS);
3032 }
3033 }
3034
3035 const estDone = clampNum(
3036 Math.max(Number.isFinite(doneBytes) ? doneBytes : 0, Math.round((elapsedMs / 1000) * bps)),
3037 0,
3038 totalBytes
3039 );
3040 const pct = clampNum(Math.round((estDone / Math.max(1, totalBytes)) * 100), 0, 97);
3041 const etaMs = Math.max(0, Math.round(((totalBytes - estDone) / Math.max(1, bps)) * 1000));
3042 return { pct, estDone, etaMs, bps };
3043}
3044
3045function setEncryptedClassForRenderedSubtree(folder, encrypted) {
3046 try {

Callers 1

renderCryptoJobUiFunction · 0.85

Calls 2

readCryptoEstimateSpeedFunction · 0.85
clampNumFunction · 0.85

Tested by

no test coverage detected