Files
factorio-clusterio/test/lib
bbassieandClaude Opus 4.8 3883c1932c Discard the temporary file when a download fails
downloadFile opens a write stream before fetching, but only closed the
stream and removed the file it was writing to when the server answered
with a bad status. A request that never reached the server, or a
connection dropped part way through the body, left both the temporary file
and an open file handle behind.

Mods are downloaded through this in a Promise.all over every mod in a pack,
so one bad moment on the network scatters temporary files across the mods
directory. They are not harmless: createTempWriteStream picks the first
free name, so each leftover file permanently shifts the name used for
later downloads of the same mod, as the existing "should not overwrite
existing temp files" test describes.

Move the fetch and the body write into a try block and discard the stream
and its file on the way out. Destroy rather than end the stream, as the
content is being thrown away, and skip both if the stream has already
closed so that a failure after the body was written does not wait forever
for a close event that has already fired.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-23 22:26:18 +00:00
..
2024-01-15 03:49:41 +01:00
2026-04-09 22:53:13 +02:00
2026-04-09 22:53:13 +02:00
2026-04-09 22:53:13 +02:00
2026-04-09 22:53:13 +02:00
2023-07-28 16:03:29 +02:00
2026-04-09 22:53:13 +02:00
2026-06-26 22:15:28 +01:00