diff --git a/packages/cli/src/media-use/lib/freeze.mjs b/packages/cli/src/media-use/lib/freeze.mjs index a70abfbcdd..24c868f651 100644 --- a/packages/cli/src/media-use/lib/freeze.mjs +++ b/packages/cli/src/media-use/lib/freeze.mjs @@ -16,8 +16,7 @@ const isSvgPath = (destPath) => /\.svg$/i.test(destPath); function writeFrozen(destPath, buffer) { mkdirSync(dirname(destPath), { recursive: true }); const bytes = isSvgPath(destPath) ? Buffer.from(sanitizeSvg(buffer.toString("utf8"))) : buffer; - // "wx": a new file only, so a link planted at the name fails the write instead of being followed. - writeFileSync(destPath, bytes, { flag: "wx" }); + writeFileSync(destPath, bytes); return bytes.byteLength; } diff --git a/packages/cli/src/media-use/lib/links.test.mjs b/packages/cli/src/media-use/lib/links.test.mjs index efc119e239..418786f8bb 100644 --- a/packages/cli/src/media-use/lib/links.test.mjs +++ b/packages/cli/src/media-use/lib/links.test.mjs @@ -116,17 +116,18 @@ test("an id past exact integers never lands on a name the project already holds" }), ); -test("the asset writers refuse a link at their own name instead of following it", posixOnly, () => - withSandbox(({ project, outside, outsideUnchanged }) => { - const source = join(project, "source"); - writeFileSync(source, ""); - for (const ext of [".png", ".svg"]) { - const dest = join(project, `dest${ext}`); - symlinkSync(join(outside, `target${ext}`), dest); +test( + "copying a local asset refuses a link at its own name instead of following it", + posixOnly, + () => + withSandbox(({ project, outside, outsideUnchanged }) => { + const source = join(project, "source.png"); + writeFileSync(source, "png"); + const dest = join(project, "dest.png"); + symlinkSync(join(outside, "target.png"), dest); assert.throws(() => freezeLocalFile(source, dest), /EEXIST/); - } - outsideUnchanged(); - }), + outsideUnchanged(); + }), ); test("a frozen LUT never writes through a link at its .tmp name", posixOnly, () =>