Repository navigation
Description
Summary
nemar dataset download <id> displays 100% N/N files from almost the first file completion — the progress bar never climbs, and the final numbers shown mid-download disagree across runs of the same dataset (observed 381/381 · 4.7 GB on one run, 222/222 · 1.7 GB on another for nm000132).
Root cause
DownloadProgressTracker in src/lib/progress.ts is constructed with filesTotal = 0. On every file completion event, processLine does:
```ts
if (this.filesTotal === 0 || this.filesCompleted > this.filesTotal) {
this.filesTotal = this.filesCompleted;
}
```
(see src/lib/progress.ts:110-122)
So the denominator is pinned to the numerator, which guarantees 100%. Byte totals also come only from git-annex's total-size events, which are reported per-file as git-annex queries the S3 remote — that's why the displayed total bytes vary run-to-run.
Fix
- Pre-count files and bytes needing download before calling
git annex get. Usegit annex find --not --in=here --json(or equivalent) to get the list of files still to fetch and sum their sizes. Pass both to the tracker viasetFilesTotaland a newsetBytesTotal. - Compute progress percentage from bytes (more stable than file count when file sizes vary wildly), keep file count as a secondary stat.
- Remove the `filesTotal = filesCompleted` fallback in `processLine` — once `filesTotal` is set authoritatively, stop mutating it.
- Add a unit test using a scripted sequence of `byte-progress` and `ok` JSON lines to verify monotonic progression 0→100%.
Files touched
- `src/lib/progress.ts` — core fix
- `src/lib/git-annex.ts` — add a helper that returns pending-file count + total bytes (wraps `git annex find --not --in=here --json`)
- `src/commands/dataset.ts` (download and get commands) — call pre-count before starting the stream
- Add `test/progress.test.ts` (or equivalent)
Acceptance
- Downloading `nm000132` shows the bar progressing monotonically 0% → 100% with file count climbing alongside.
- Final byte total matches `du -sh` of annexed files within rounding.
- Unit test covers the tracker with a fixed input sequence.
Activity
fix(download): pre-count files+bytes for accurate progress (#346)
Merge pull request #373 from nemarOrg/feature/issue-346-download-prog…
neuromechanist commentedon May 14, 2026
Closing as already fixed on
dev.PRs #373 and #375 shipped the fix:
src/lib/progress.ts:202,211hassetFilesTotalandsetBytesTotalsrc/lib/git-annex.ts:1538exportscountPendingDownload(usesgit annex find --not --in=here --json)downloadandgetcommands pre-count files+bytes and pass them to the trackertest/progress.test.tshas 10 tests including monotonic 0→100 and a regression-guard against thefilesTotal = filesCompletedmutationVerified during a parallel cleanup batch (May 2026).