Skip to content

Add download all button to shared folder page#44

Open
zmeyer44 wants to merge 1 commit into
mainfrom
download-all-shared-folder
Open

Add download all button to shared folder page#44
zmeyer44 wants to merge 1 commit into
mainfrom
download-all-shared-folder

Conversation

@zmeyer44

Copy link
Copy Markdown
Owner

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.getDownloadUrl mutation for each. The existing handleDownload was refactored into a bare downloadFile helper so the single-file buttons and the bulk button share one code path.

Behavior notes / review asks

Two judgment calls worth a look:

  • Not recursive. The button downloads files in the current folder view only. Navigating into a subfolder gives a fresh "Download all" for that level. Recursion is easy to add, but one click silently pulling an entire tree seemed like the wrong default.
  • Counts N against maxDownloads. Each file consumes one of the share link's download budget, since that's how shares.getDownloadUrl already 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/archiver dependency, 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 .zip is preferred, that's the natural follow-up, and it would also let the download count as one against maxDownloads instead of N.

Testing

tsc --noEmit passes 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

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>
@vercel

vercel Bot commented Jul 17, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
locker-web Ready Ready Preview, Comment Jul 17, 2026 2:10pm

Request Review

@greptile-apps

greptile-apps Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds bulk downloads to the shared-folder page. The main changes are:

  • A reusable helper for fetching and downloading one file.
  • A sequential loop that downloads every displayed file.
  • A full-width button with progress state and aggregated failure feedback.

Confidence Score: 4/5

The bulk-download path can use stale folder data and can silently treat browser-blocked downloads as successful.

  • Moving between subfolders can leave the button bound to the previous folder's files.
  • Repeated synthetic downloads provide no signal when the browser blocks later files.
  • Server-side authorization and folder-scope checks remain intact.

apps/web/app/shared/[token]/page.tsx

Important Files Changed

Filename Overview
apps/web/app/shared/[token]/page.tsx Adds the shared download helper, sequential bulk-download flow, progress state, and folder-view button.

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)}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 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.

Comment on lines +89 to +94
for (const file of files) {
try {
await downloadFile(file.id);
} catch {
failed++;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 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.

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.

1 participant