Skip to content

fix: allow downloading files inside asar archives - #52808

Merged
MarshallOfSound merged 2 commits into
mainfrom
fix-asar-download
Aug 15, 2026
Merged

MarshallOfSound merged 2 commits into
mainfrom
fix-asar-download

Conversation

@codebytere

Copy link
Copy Markdown
Member

Description of Change

Closes #49475.

Downloads read file: URLs straight from disk through content's FileURLLoaderFactory rather than Electron's asar-aware loader, so the PDF viewer's Save button on a packed PDF (an unedited document is saved by the browser as a download of the frame URL) and webContents.downloadURL() of any packed file both failed after the save dialog with the virtual path not existing. WebContents now handles WebContentsDelegate::SaveFrame() and translates downloadURL(), so a file: URL that points into an archive is downloaded from an extracted copy of the entry and named after the entry - no Chromium patch involved.

Checklist

  • PR description included and stakeholders cc'd
  • npm test passes
  • tests are changed or added
  • PR release notes describe the change in a way relevant to app developers

Release Notes

Notes: Fixed downloading files that live inside an asar archive, including saving a packed PDF from the built-in PDF viewer.

@electron-cation electron-cation Bot added the new-pr 🌱 PR opened recently label Aug 14, 2026
@codebytere codebytere added semver/patch backwards-compatible bug fixes target/42-x-y PR should also be added to the "42-x-y" branch. target/43-x-y PR should also be added to the "43-x-y" branch. target/44-x-y PR should also be added to the "44-x-y" branch. labels Aug 14, 2026
Downloads read file: URLs straight from disk through content's
FileURLLoaderFactory rather than Electron's asar-aware loader, so the
PDF viewer's Save on a packed PDF, and webContents.downloadURL() of any
packed file, failed with the virtual path not existing. Handle
WebContentsDelegate::SaveFrame() and translate downloadURL() so a file:
URL that points into an archive is downloaded from an extracted copy of
the entry, named after the entry.

Closes #49475.
@codebytere
codebytere requested a review from deepak1556 August 14, 2026 14:22
@electron-cation electron-cation Bot removed the new-pr 🌱 PR opened recently label Aug 15, 2026
@MarshallOfSound
MarshallOfSound merged commit 8fd4d10 into main Aug 15, 2026
79 checks passed
@release-clerk

release-clerk Bot commented Aug 15, 2026

Copy link
Copy Markdown

Release Notes Persisted

Fixed downloading files that live inside an asar archive, including saving a packed PDF from the built-in PDF viewer.

@trop

trop Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "43-x-y", please check out #52826

@trop

trop Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "44-x-y", please check out #52827

@trop trop Bot removed the target/43-x-y PR should also be added to the "43-x-y" branch. label Aug 15, 2026
@trop

trop Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "42-x-y", please check out #52828

@trop trop Bot added in-flight/44-x-y in-flight/42-x-y and removed target/44-x-y PR should also be added to the "44-x-y" branch. target/42-x-y PR should also be added to the "42-x-y" branch. in-flight/43-x-y labels Aug 15, 2026
@trop trop Bot added merged/43-x-y PR was merged to the "43-x-y" branch. merged/44-x-y PR was merged to the "44-x-y" branch. merged/42-x-y PR was merged to the "42-x-y" branch. and removed in-flight/44-x-y in-flight/42-x-y labels Aug 16, 2026
Comment on lines +166 to +167
base::FilePath extracted_path;
if (!archive || !archive->CopyFileOut(relative_path, &extracted_path))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

the extracted packed filesystem resource will be kept alive for the process lifetime, is it worth keeping them alive for one shot download paths ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

45-x-y merged/42-x-y PR was merged to the "42-x-y" branch. merged/43-x-y PR was merged to the "43-x-y" branch. merged/44-x-y PR was merged to the "44-x-y" branch. semver/patch backwards-compatible bug fixes

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Cannot save/download PDF from ASAR file in PDF viewer

3 participants