fix: fix remote astro:assets caching logic (#8424)

This commit is contained in:
Matteo Manfredi 2023-09-06 02:28:00 +02:00 committed by GitHub
parent 923a443cb0
commit 61ad70fdc5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Fixes remote assets caching logic to not use expired assets

View file

@ -75,7 +75,7 @@ export async function generateImage(
const JSONData = JSON.parse(readFileSync(cachedFileURL, 'utf-8')) as RemoteCacheEntry; const JSONData = JSON.parse(readFileSync(cachedFileURL, 'utf-8')) as RemoteCacheEntry;
// If the cache entry is not expired, use it // If the cache entry is not expired, use it
if (JSONData.expires < Date.now()) { if (JSONData.expires > Date.now()) {
await fs.promises.writeFile(finalFileURL, Buffer.from(JSONData.data, 'base64')); await fs.promises.writeFile(finalFileURL, Buffer.from(JSONData.data, 'base64'));
return { return {