Skip to content

Fix eta calculation - #166

Open
8nt0n wants to merge 7 commits into
LeyckerS:mainfrom
8nt0n:fix-eta-calculation
Open

Fix eta calculation#166
8nt0n wants to merge 7 commits into
LeyckerS:mainfrom
8nt0n:fix-eta-calculation

Conversation

@8nt0n

@8nt0n 8nt0n commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Fixes #85

Description

This PR resolves multiple accuracy, stability, and edge-case issues in the ETA calculation logic (moon_engine.py and app.js):

  • ETA Clamp Fix: Updated raw_eta >= 7200 to return None (instead of the 7200 sentinel), allowing app.js to properly render --.
  • Direct Remaining-Bytes Calculation: Replaced early-run average-file-size skew by calculating remaining bytes using known file_bytes for in-flight files and applying average estimates only to pending files without known sizes.
  • Jitter Reduction: Decoupled the live UI speed display (3-second window) from the ETA calculation speed (10-second smoothed window).
  • Terminal State Filter: Excluded non-active states (ok, fail, aborted, stopped) from _tracked so failed or aborted partial downloads no longer contribute ghost remaining bytes to the ETA.
  • Code Cleanup & Tests: Cleaned up dead code (t_start), updated window comments, and added unit tests in test_snapshot_speed.py covering clamp behavior and terminal-state handling.

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would change existing behavior)
  • Documentation update
  • Refactor / code cleanup
  • Other:

Checklist

  • I have tested my changes locally
  • If this affects shared logic (extraction, download engine), I also applied the equivalent change to moon_cli.py
  • I have kept the single-file architecture (no package split)
  • I have not added new dependencies without justification in the PR description

8nt0n and others added 7 commits August 10, 2026 02:06
- Exclude 'ok', 'fail', 'aborted', and 'stopped' files from remaining ETA byte count
- Remove unused t_start variable and clarify ETA smoothing window comments
- Add test_snapshot_eta_ignores_terminal_states test case
Remove unused variable t_start from eta calculation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

eta: the estimate clamps to exactly 2 hours and presents it as a real number

1 participant