Skip to content

Commit 037b695

Browse files
authoredMar 19, 2024
perf: ensure blob directory exist just once (#357)
* perf: ensure blob directory exist just once * fix: lint
1 parent 416f66c commit 037b695

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed
 

‎src/build/content/prerendered.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { existsSync } from 'node:fs'
22
import { mkdir, readFile, writeFile } from 'node:fs/promises'
3-
import { dirname, join } from 'node:path'
3+
import { join } from 'node:path'
44

55
import { glob } from 'fast-glob'
66
import type { CacheHandlerValue } from 'next/dist/server/lib/incremental-cache/index.js'
@@ -29,7 +29,6 @@ const writeCacheEntry = async (
2929
value,
3030
} satisfies CacheHandlerValue)
3131

32-
await mkdir(dirname(path), { recursive: true })
3332
await writeFile(path, entry, 'utf-8')
3433
}
3534

@@ -81,6 +80,8 @@ const buildFetchCacheValue = async (path: string): Promise<CachedFetchValue> =>
8180
*/
8281
export const copyPrerenderedContent = async (ctx: PluginContext): Promise<void> => {
8382
try {
83+
// ensure the blob directory exists
84+
await mkdir(ctx.blobDir, { recursive: true })
8485
// read prerendered content and build JSON key/values for the blob store
8586
const manifest = await ctx.getPrerenderManifest()
8687

0 commit comments

Comments
 (0)
Please sign in to comment.