Add download all button to shared folder page#44
Conversation
Adds a "Download all (N)" button to the folder view of the shared link page. Refactors the existing single-file download into a bare downloadFile helper so the per-file buttons and the bulk button share one code path. Downloads run sequentially rather than in parallel: each file consumes one of the share link's maxDownloads budget, and parallel blob clicks get throttled by the browser. Failures are tallied into a single toast instead of one per file. Scoped to the files in the current folder view, not recursive into subfolders. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryThis PR adds bulk downloads to the shared-folder page. The main changes are:
Confidence Score: 4/5The bulk-download path can use stale folder data and can silently treat browser-blocked downloads as successful.
apps/web/app/shared/[token]/page.tsx Important Files Changed
Reviews (1): Last reviewed commit: "Add download all button to shared folder..." | Re-trigger Greptile |
| size="sm" | ||
| className="w-full" | ||
| disabled={isDownloadingAll} | ||
| onClick={() => handleDownloadAll(displayFiles)} |
There was a problem hiding this comment.
Previous Folder Files Stay Active
When the user moves directly between subfolders, the query can retain the previous folder's data while fetching the next folder. Because this button remains enabled with those stale file IDs, clicking it during the transition downloads files from the previous folder and consumes their download allowance.
| for (const file of files) { | ||
| try { | ||
| await downloadFile(file.id); | ||
| } catch { | ||
| failed++; | ||
| } |
There was a problem hiding this comment.
Blocked Downloads Count As Success
Browsers can block or prompt for repeated automatic downloads after the first asynchronous a.click(), but a blocked click does not reject downloadFile. The loop then reports success even when only some files were delivered, while each requested URL has already consumed the share link's download allowance.
Summary
Adds a Download all (N) button to the folder view of the shared link page (
/shared/[token]).It loops over the files currently displayed and reuses the existing
trpc.shares.getDownloadUrlmutation for each. The existinghandleDownloadwas refactored into a baredownloadFilehelper so the single-file buttons and the bulk button share one code path.Behavior notes / review asks
Two judgment calls worth a look:
maxDownloads. Each file consumes one of the share link's download budget, since that's howshares.getDownloadUrlalready counts. This is pre-existing behavior for the per-file buttons, but this button makes it much easier to hit the cap by accident.Downloads run sequentially rather than in parallel — parallel blob clicks get throttled by the browser. Failures are tallied into a single toast rather than one per file.
Not zipping (deliberate)
There's no zip capability anywhere in the repo — no
jszip/archiverdependency, no bulk route — so a real zip means a new dependency plus a server route streaming from the storage abstraction. That was a bigger change than the request implied. If a single.zipis preferred, that's the natural follow-up, and it would also let the download count as one againstmaxDownloadsinstead of N.Testing
tsc --noEmitpasses clean for the changed file. Not exercised in a running app — the download path is worth a manual click-through before merge.🤖 Generated with Claude Code