fix(artifacts): make extraction output tree work on Windows (#753)

SafeOutputTree.create() called fchmod(0o700) on a directory handle and
commit() fsynced a directory handle. Both are POSIX-only: Windows rejects
them with EPERM ("operation not permitted, fchmod"/"fsync"), so every
extract_artifact call failed with a generic io error and produced no output.

Skip the redundant directory chmod and directory fsync on Windows. mkdir
already applies the requested mode, and file contents are synced in write().
Add a Windows regression test and run it, plus the archive-safety test, in
the curated Windows CI lane so the behavior is covered.
This commit is contained in:
Dery Ferdika
2026-10-07 01:46:52 +08:00
committed by GitHub
parent 91daaa68ae
commit c8e66c704a
3 changed files with 47 additions and 12 deletions
@@ -81,4 +81,18 @@ describe("safe artifact output tree", () => {
residualPaths: [],
});
});
it("publishes without POSIX-only directory chmod or fsync on Windows", async () => {
const parent = await createTestTempDirectory("rea-safe-output-");
const output = join(parent, "published");
const tree = await SafeOutputTree.create(output, "win32");
const bytes = Buffer.from("windows output");
const digest = createHash("sha256").update(bytes).digest("hex");
await tree.write("nested/file.txt", Readable.from(bytes), digest);
await tree.commit();
expect(await readFile(join(output, "nested", "file.txt"), "utf8")).toBe(
"windows output",
);
});
});