diff --git a/packages/lib/factorio/patch.js b/packages/lib/factorio/patch.js index 7f92232f..8e0c6a0f 100644 --- a/packages/lib/factorio/patch.js +++ b/packages/lib/factorio/patch.js @@ -251,8 +251,14 @@ async function patch(savePath, modules) { // Write back the save let tempSavePath = `${savePath}.tmp`; let stream = zip.generateNodeStream({ compression: "DEFLATE" }); - let pipe = stream.pipe(fs.createWriteStream(tempSavePath)); - await events.once(pipe, "finish"); + let fd = await fs.open(tempSavePath, "w"); + try { + let pipe = stream.pipe(fs.createWriteStream("", { fd, autoClose: false })); + await events.once(pipe, "finish"); + await fs.fsync(fd); + } finally { + await fs.close(fd); + } await fs.rename(tempSavePath, savePath); }