Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure final asset directory exists before writing cached files #12418

Merged
merged 3 commits into from
Nov 15, 2024

Conversation

oliverlynch
Copy link
Contributor

Changes

Create the asset output folder before writing from cache.

If the first optimised image asset is cached astro re-optimises it as the cached file could not be written to the output directory, which is created after the cache step. Instead create the output directory first to prevent the unnecessary redownload and reprocessing of the first image asset.

Testing

Tested with the astro base template with a single remote image with 3 densities added, and successfully ran pnpm --filter astro run test.
Improved test site optimised image generation time on rebuilds from ~280ms to ~1ms, although this is an extreme case.

Docs

N/A: Minor fix in caching behaviour that should conform to existing user expectations

Copy link

changeset-bot bot commented Nov 12, 2024

🦋 Changeset detected

Latest commit: fc486fa

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Nov 12, 2024
Copy link
Member

@Princesseuh Princesseuh left a comment

Choose a reason for hiding this comment

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

Looks great to me! Thank you very much for contributing this fix!

@Princesseuh Princesseuh merged commit 25baa4e into withastro:main Nov 15, 2024
13 of 14 checks passed
This was referenced Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants